RSS

PROGRAM TO FIND THE NUMBER OF TRAILING ZEROES IN THE FACTORIAL OF A NUMBER

21 Apr
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main()
{
  long long int i = 0,num;
     cin>>num;
     long long power = 1,facts = 0;
     while(floor(num/pow(5,power)) != 0)
     {
       facts += floor(num/pow(5,power));
       power++;
     }
     cout<<facts<<'\n';
    return 0;
} 
Advertisements
 
Leave a comment

Posted by on April 21, 2016 in Miscellaneous Programs

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: