您的位置:首页 > 其它

100的阶乘末尾有多少个零?

2009-11-06 12:08 519 查看
100! = m * 10n
; 其中 m不被10整除,n就是100!末尾零的个数。由于2的个数比5多,所以只要计算5的个数就可以了。

#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int count = 0;
for (int i=1; i!=101; i++)
for (int j=i; !(j%5) && j>0; j/=5)
count++;
cout << count;
system("PAUSE");
return EXIT_SUCCESS;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: