Problem 114: F...... Factorials
(U.M. ACM Runoffs 2003, problem 1)
Description
The factorial of a number is defined to be the product of
(i.e. multiply together) all the intgers between 1 and that
number. So, for example the factorial of 5 is
1×2×3×4×5, which is 120.
By definition, the factorial of zero is 1.
The symbol for factorial is an exclamation mark '!', so
the above example is normally written as 5!=120.
Write a program that calculates the factorials of numbers
with perfect accuracy.
Input Format
The input will consist of some number of lines; each
line will contain one input number. All numbers will
be non-negative except for the very last one. The last
line of input will contain a negative number which is
simply marks the end of the inputs; do not attempt
to calculate its factorial.
Output Format
For each input, produce a single line of output. The
output line should contain the input number, immedaitely
followed by an '!', immediately followed by a space,
immediately followed by an '=', immediately followed by
a space, immediately followed by the answer.
No matter how long the answer is, print it all on one
line, completely uninterrupted.
Limits
All inputs will be between 0 and 1000 inclusive
Sample Input
5
0
3
9
-1
Sample Output
5! = 120
0! = 1
3! = 6
9! = 362880
End of Problem