Skip to content

Commit 5c381b5

Browse files
Merge pull request #32 from Anshsahu0802/main
organized CPP code and added new folder wise code
2 parents 6671d88 + 5af91d5 commit 5c381b5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

CPP/questions/trailZeros.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
//This program prints the number of zeros in a factorial.
5+
6+
int countZero(int n)
7+
{
8+
int res = 0;
9+
for(int i = 5;i<=n;i = i*5)
10+
{
11+
res = res + n/i;
12+
}
13+
return res;
14+
}
15+
16+
17+
int main()
18+
{
19+
20+
int n;
21+
cin>>n;
22+
23+
cout<<countZero(n)<<endl;
24+
}

0 commit comments

Comments
 (0)