#include<iostream>
using namespace std;
const int size = 6; //输入阶乘数
int main()
{
long long factorial[size];
factorial[1] = factorial[0] = 1LL;
for (int i = 2; i < size; i++)
{
factorial[i] = i * factorial[i - 1];
}
for (int i = 0; i < size; i++)
cout << i << "! = " << factorial[i] << endl;
cin.get();
return 0;
}
输出:
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120