在第二层循环里,你的s没有清零。其实你不用这样写的。
将代码改为:
int i, j, s = 0, n = 1;for(i = 1; i <= 9999; i++){ s += i; n *= s; if(n > 10000) { printf("%d\n", i); break; }}