Formula used:
Trailing 0s in N! = Count of 5s in prime factors of n!
= floor(n/5) + floor(n/25) + floor(n/125) + ....
Example:
Input: N = 23
Output: 4
Factorial of 23 is 25852016738884976640000 which has four trailing 0.
Input: N = 25
Output: 6
Factorial of 25 is 15511210043330985984000000 which has six trailing 0.
Code:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer