求整数n>0的阶乘和 C语言
#include <stdio.h> int main() { int n = 0; while(scanf("%lld", &n) && n > 0) { long long sum = 0; for(int i = 1; i <= n; i++) { long long factorial = 1; for (int j = 1; j <= i; j++) { factorial *= j; } sum += factorial; } printf("%lld的阶乘和为:%lld\n", n, sum); } return 0; }