C Program to print the number of Trailing Zeroes in the Factorial of a Number


 

// Program by Akash Tripathi (@proakash256) 
 
// 0 comes because of multiplying 2 and 5.
// So we count the number 5's in the number
// by dividing it with perfect
// multiples of 5.
#include <stdio.h>
int main()
{
    int n , res = 0;
    printf("Enter the Number : ");
    scanf("%d" , &n);
    for(int i = 5i <= ni = i * 5)
    {
        res = res + (n / i);
    }
    printf("\nThe Number of Trailing Zeroes
             in %d is %d\n\n" , n , res);
    return 0;
}

Comments