#include#define nmax 100000 int num[nmax]; void solve(int n) { int i, j, k, r; for (i = 1, num[0] = 1, k = 0, r = 0; i <= n; i++) { for (j = 0; j <= k; j++) { num[j] = num[j] * i + r; if (num[j] >= nmax) { r = num[j] / nmax; num[j] = num[j] % nmax; } else { r = 0; } } if (r) { num[++k] = r; r = 0; } } printf("%d", num[k]); for (i = k - 1; i >= 0; i--) { printf("%05d", num[i]); } printf("\n"); } int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif int n; while (~scanf("%d", &n)) { solve(n); } return 0; }
import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { int a, i; Scanner cin = new Scanner(System.in); while (cin.hasNextInt()) { a = cin.nextInt(); BigInteger n = BigInteger.valueOf(1); if (a == 0) { System.out.println("1"); } else { for (i = 1; i <= a; i++) n = n.multiply(BigInteger.valueOf(i)); System.out.println(n); } } } }