/home/toolbox/public_html/solutions/6/623/a623.java
1 import java.util.Scanner;
2 import java.math.BigInteger;
3
4 // To submit to UVA (online judge), the class line becomes:
5 // class Main {
6 // instead of
7 // public class a623 {
8 class Main
9 {
10 public static void main(String[] args)
11 {
12 int num;
13 BigInteger[] fac;
14
15 fac = new BigInteger[1005];
16 fac[0] = BigInteger.valueOf(1);
17 fac[1] = BigInteger.valueOf(1);
18 for (int i = 2; 1001>i; i++)
19 {
20 // calculate each factorial
21 fac[i] = fac[i-1].multiply(BigInteger.valueOf(i));
22 } // calculate each factorial
23
24 Scanner sc = new Scanner(System.in);
25 while (sc.hasNext())
26 {
27 num = sc.nextInt();
28 System.out.println(num+"!");
29 System.out.println(fac[num]);
30 }
31 }
32 }
33
34