自己練習寫的n!末尾零的個數的代碼

#include "iostream"
using namespace std;
int main()
{
int count=0;
int n,i;
cin>>n;
for(i=n;i>=1;i--)
{
while(i%5==0&&i!=1)
{
count++;
i=i/5;
}
}
cout<<count<<endl;
system("pause");
return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章