#include <stdio.h> #include <stdint.h> #include <inttypes.h> int main( void ) { uint64_t sum = 0; uint64_t factorial = 1; for( unsigned i=0; i!=20; ++i ) { factorial *= i+1; sum += factorial; } printf( "1!+2!+3!+...+20! = %"PRIu64"\n", sum ); }
#include<stdio.h> int main() { int i,j; __int64 sum=0,k; for(i=1;i<=20;i++) { k=1; for(j=1;j<=i;j++) { k=k*j; } sum=sum+k; } printf("1+2!+3!+...+20!=%I64d",sum); return 0; }
[此贴子已经被作者于2021-7-4 11:29编辑过]
[此贴子已经被作者于2021-7-5 14:42编辑过]