You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

903 B

spelling

Instructions

In this exercise, you'll create the function spell that will spell a generated number.

Here are some examples of what your function should return:

  • 1 -> "one"
  • 14 -> "fourteen".
  • 96 -> "ninety-six"
  • 100 -> "one hundred".
  • 101 -> "one hundred one"
  • 348 -> "one hundred twenty-three"
  • 1002 -> "one thousand two".
  • 1000000 -> "one million"

Only positive numbers will be tested, up to "one million".

Expected function

pub fn spell(n: u64) -> String {

}

Usage

Here is a program to test your function.

use spelling::*;

fn main() {
    println!("{}", spell(348));
    println!("{}", spell(9996));
}

And its output:

$ cargo run
three hundred forty-eight
nine thousand nine hundred ninety-six
$

Notions