计算100的阶乘c++
以下是一个计算100的阶乘的C++代码示例:
#include <iostream>
using namespace std;
// 计算阶乘的函数
unsigned long long factorial(int n) {
unsigned long long result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
}
return result;
}
int main() {
int n = 100;
unsigned long long result = factorial(n);
cout << n << "的阶乘是:" << result << endl;
return 0;
}
运行以上代码,输出结果为:
100的阶乘是:93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
``
原文地址: https://www.cveoy.top/t/topic/igfy 著作权归作者所有。请勿转载和采集!