写了个求1!+2!+。。。+20!的程序。不知道错哪了,值不对
#include<stdio.h>int main(void){
int x,y,t;
y=1;
int i=0;
for(x=1;x<=20;x++){
for(t=1;t<=x;t++){
y=y*t;
}
i=i+y;
}
printf("%d",i);
return 0;
}
#include <stdio.h> int main( void ) { unsigned long long sum=0, factorial=1; for( unsigned i=1; i<=20; ++i ) { factorial *= i; sum += factorial; } printf( "%llu\n", sum ); // 2561327494111820313 }