Академический Документы
Профессиональный Документы
Культура Документы
Write a program that takes an integer and displays the English name of that value.
You should support both positive and negative numbers, in the range supported by a 32-bit integer
(approximately -2 billion to 2 billion).
Examples:
10 -> ten
121 -> one hundred twenty one
1032 -> one thousand thirty two
11043 -> eleven thousand forty three
1200000 -> one million two hundred thousand
Factorial Challenge
Here's a challenge that's a bit more mathematical in nature. Write a program that determines the
number of trailing zeros at the end of X! (X factorial), where X is an arbitrary number. For instance, 5!
is 120, so it has one trailing zero. (How can you handle extremely values, such as 100!?) The input
format should be that the program asks the user to enter a number, minus the !.
The way to compute any given position's value is to add up the numbers to
the position's right and left in the preceding row. For instance, to compute
the middle number in the third row, you add 1 and 1; the sides of the
triangle are always 1 because you only add the number to the upper left or
the upper right (there being no second number on the other side).
The program should prompt the user to input a row and a position in the
row. The program should ensure that the input is valid before computing a value for the position.