Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*program to find number of trailing 0's in factorial of a number*/
- #include <iostream>
- using namespace std;
- int main()
- {
- int num,div=5,i,count=0;
- cout<<"PROGRAM TO FIND NUMBER OF TRAILING 0'S IN FACTORIAL OF A NUMBER"
- cout<<"\nENTER THE NUMBER : "
- cin>>num;
- while(div<num)
- {
- i=num/div;
- count+=i;
- div=div*5;
- }
- cout<<"\nNUMBER OF TRAILING 0'S IN FACTORIAL OF "<<num<<"ARE : "<<count;
- return 0;
- }
Add Comment
Please, Sign In to add comment