C Function Programs

Count trailing zeroes in factorial of a number

Count trailing zeroes in factorial of a number – Given an integer ‘n’ , we need to calculate number of zeroes in the factorial of that number.

Count trailing zeroes in factorial of a number

One simple method to do this to calculate the factorial of the number and then count the trailing zeroes in the result.This method can result in overflow sometimes when the value is very large.

The other simple method is that, we count the number of 5 is the prime factor of n!

Implementing this logic in C


Output:

Count trailing zeroes in factorial of a number

Summary
Count trailing zeroes in factorial of a number
Article Name
Count trailing zeroes in factorial of a number
Description
Count trailing zeroes in factorial of a number - Given an integer 'n' , we need to calculate number of zeroes in the factorial of that number.
Author
Publisher Name
Scanfcode
Publisher Logo