next up previous
Next: Lawnmower Reachability Up: 1997 UMCP High School Programming Contest Previous: Symmetric Matrices

Computing Factorial for Large Numbers

Write a program that computes the factorial function for an input positive integer n. We define

displaymath142

The goal is to compute factorial for large numbers. So you must compute all the digits accurately. You may assume that the output has at most 100 digits.

Input Format

Each line contains a positive integer for which you must compute a factorial. A line containing zero indicates end of input.

Output Format

Output the factorial for each input, each on its own line.

Example

Input: Output:
5
20
0
120
2432902008176640000

Test data used in judging

Input Output

Our solution



next up previous
Next: Lawnmower Reachability Up: 1997 UMCP High School Programming Contest Previous: Symmetric Matrices

Bill Pugh
Mon Mar 17 14:34:34 EST 1997