Showing posts with label Trailing zeroes in factorial. Show all posts
Showing posts with label Trailing zeroes in factorial. Show all posts

Sunday, October 11, 2015

Find no. of Trailing zeroes in factorial of given number

trailing zeroes depends on no. of 5's and 2's .

total=no. of 5's.
#include <iostream>
using namespace std;
int main()
{
int a=trailingZeroes(12);
cout<<a;
}
int trailingZeroes(int A) {
    int count=0;
    while(A>=5)
    {
        count=count+A/5;
        A=A/5;
    }
    return count;
}

Contributors

Translate