求1到25的阶乘和,结果是16158688114800553828940313 但是程序不会写!谢谢谢谢谢谢
#include <stdio.h> long a[1000] = {1}, s[1000] = {1}; int alast = 0, slast = 0; int main(void) { int n = 25, t; for (t = 2; t <= n; t++) { int i, tmp; for (tmp = i = 0; i <= slast; i++) { tmp += s[i] * t; s[i] = tmp % 10000; tmp /= 10000; if (i == slast && tmp != 0) slast++; } if (alast < slast) alast = slast; for (tmp = i = 0; i <= alast; i++) { tmp += a[i] + s[i]; a[i] = tmp % 10000; tmp /= 10000; if (i == alast && tmp != 0) alast++; } } printf("%ld", a[alast]); for (t = alast - 1; t >= 0; t--) printf("%04ld", a[t]); putchar('\n'); return 0; }