求解答万分感谢
用递归函数编程计算1!+3!+5 +···+n!(n为奇数)
#include <stdio.h> //gcc编译时取消下行注释 //#include <inttypes.h> unsigned long long foobar(int n) { unsigned long long foo; if(1 == n || 0 == n) { foo = 1; } else { foo = foobar(n - 1) * n; } return foo; } unsigned long long add(int n) { unsigned long long sum = 0; if(1 == n) { sum = 1; } else { sum = add(n - 2) + foobar(n); } return sum; } int main(void) { int n; printf("INPUT N: "); scanf("%d", &n); if(n >= 3 && n % 2 != 0) { //gcc编译时取消下行注释 //printf("1!+3!+...+n! = %"PRIu64"\n", add(n)); printf("1!+3!+...+n! = %lld\n", add(n)); } else { printf("input arror!\n"); } return 0; }