#include <stdio.h> #include <stdlib.h> #define N 10000 int main(int argc, char ** argv) { int i, j, k, l, m; int result[N] = {1, 1}; if (argc != 2 || (m = atoi(argv[1])) <= 0) { printf("Parameter error!/n/nUsage: /"big [NUMBER]/" NUMBER: The factorial number./n/nNUMBER unsigned number should not be zero and not greater than 3000/n/n"); return 1; } if (m > 3000) { printf("Result out of range!/n/nNUMBER <= 3000/n/n"); return 1; } for (i = 2; i <= m; ++i) { k = result[0]; for (j = 1; j <= k; ++j) result[j] *= i; for (j = 1; j < k; ++j) if (result[j] >= 10) { result[j+1] += result[j]/10; result[j] = result[j]%10; } for (l = 1; l < 10; ++l) { if (result[k] >= 10) { result[k + 1] = result[k]/10; result[k] = result[k]%10; k++; } } result[0] = k; } for (i = result[0]; i >= 1; --i) printf("%d", result[i]); printf("/nNumbers:%d./n", result[0]); return 0; }