// UVa 623 - 500! import java.math.BigInteger; import java.util.Scanner; public class Main { static BigInteger[] fact = new BigInteger[1001]; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = 0; fact[0] = BigInteger.valueOf(1); while (scanner.hasNextInt()) { int n = scanner.nextInt(); if (n > m) { for (int i = m + 1; i <= n; i++) fact[i] = fact[i - 1].multiply(BigInteger.valueOf(i)); m = n; } System.out.println(n + "!"); System.out.println(fact[n].toString()); } } }
No comments:
Post a Comment