The code is written to find the factorial of a number and number of terminating zeros . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The code is written to find the factorial of a number and number of terminating zeros .

like if we gave 5 5! = 120 and it should it it has 1 terminating zero but my codes isn't running https://code.sololearn.com/cE79854s6ai4/?ref=app

23rd Sep 2018, 9:19 AM
Chethan.B
2 Answers
+ 2
Try this: #include <iostream> using namespace std; int cheths(int fact) { int r=0,count=0; while(fact>0) { r= fact%10; if(r==0){ count=count+1; } fact=fact/10; } return count; } int main() { int a ,fact=1; cout <<"enter the number\n"; cin>>a; for(int i=a;i>0;i--) fact=fact*i; cout<<a<<" ! = "<< fact<<endl; cout << cheths(fact); return 0; }
23rd Sep 2018, 10:25 AM
Ulisses Cruz
Ulisses Cruz - avatar
0
tysm
23rd Sep 2018, 10:28 AM
Chethan.B