写一个1的阶乘加到15的阶乘的程序

写一个1的阶乘加到15的阶乘的程序

第1个回答  2016-10-13
#include <iostream>
using namespace std;
__int64 fac (int n) {
if (n==0 || n==1)
return 1;
return n*fac(n-1);
}

int main() {
int i;
for (i=1;i<=15;i++) {
cout << i << "! = " << fac(i) << endl;
}
return 0;
}本回答被网友采纳