m2skills

trailing cpp

Apr 7th, 2017
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. /*program to find number of trailing 0's in factorial of a number*/
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int num,div=5,i,count=0;
  9.     cout<<"PROGRAM TO FIND NUMBER OF TRAILING 0'S IN FACTORIAL OF A NUMBER"
  10.     cout<<"\nENTER THE NUMBER : "
  11.     cin>>num;
  12.     while(div<num)
  13.     {
  14.         i=num/div;
  15.         count+=i;
  16.         div=div*5;
  17.     }
  18.     cout<<"\nNUMBER OF TRAILING 0'S IN FACTORIAL OF "<<num<<"ARE : "<<count;
  19.     return 0;
  20. }
Add Comment
Please, Sign In to add comment