
numberInWords
You’re practicing writing numbers in word form, according to the following rules:
The first letter is capitalized
Hyphenated words are used for numbers under 100 (eg: “Thirty-two”)
Given an integer number, return a string representing the number in word form.
Examples
- For
number = 1
, the output should benumberInWords(number) = "One".
- For
number = 12
, the output should benumberInWords(number) = "Twelve".
- For
number = 14
, the output should benumberInWords(number) = "Fourteen".
- For
number = 21
, the output should benumberInWords(number) = "Twenty-one".
- For
number = 299
, the output should benumberInWords(number) = "Two hundred ninety-nine".
- For
number = 123456
, the output should benumberInWords(number) = "One hundred twenty-three thousand four hundred fifty-six"
.
Input / Output
-
[execution time limit] 2 seconds (d)
-
[input] integer number
An integer representing the number you need to write out.
Guaranteed constraints:
1 ≤ number ≤ 106
-
[output] string
A string representing the number in word form.
Post Comment