我知道如何计算阶乘的数字,方法如下。如何计算最有效的阶乘数字
让数字n!被发现。
temp = 0.0;
for(i = 1; i <= n; i++){
temp += log(i);
}
result = (int)temp;
result++;
我在这里寻找更有效的方法来计算阶乘的位数。
注:请用C++
我知道如何计算阶乘的数字,方法如下。如何计算最有效的阶乘数字
让数字n!被发现。
temp = 0.0;
for(i = 1; i <= n; i++){
temp += log(i);
}
result = (int)temp;
result++;
我在这里寻找更有效的方法来计算阶乘的位数。
注:请用C++
这个问题的Python的解决方案编码答:
len(list(str(num)))
中下计算的数字每一个数字,你可以使用此代码:
int c=2;
while((num/10)>10) {
num=(int)a/10;
c++;
}
我不知道如何编写这种方式#Sara_Santana – mhkm
你不知道python还是没有python?如果你没有python,你可以使用在线解释器,如:[link](http://repl.it/languages/Python) –
我不明白这有助于回答问题 – thecoshman
我不确定你提供的代码甚至可以工作。有什么用' 结果++; =(int)temp;'?? – coyotte508
这是我的错误。现在纠正了。谢谢 – mhkm