用数学建模 编程求∑n! (n=1,2,3...20),即对1到20的阶乘的和!
#include int fun(int n){return n == 0 ? 1 : n * fun(n - 1); }int main(void){int i, sum = 0;for(i = 1; i <= 4; i++){sum += fun(i);}printf("%d\n", sum);return 0; }
用数学建模 编程求∑n! (n=1,2,3...20),即对1到20的阶乘的和!
#include int fun(int n){return n == 0 ? 1 : n * fun(n - 1); }int main(void){int i, sum = 0;for(i = 1; i <= 4; i++){sum += fun(i);}printf("%d\n", sum);return 0; }