Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should is in logarithmic time complexity.
Credits:
Special thanks to @ts for adding this problem and creating all test cases.
See for a long while did not read the title meaning to ask N end 0 of the number of a half-day is required n! That is, the factorial of n results in the end of how many 0 can be known when the factorial factor in a pair of 5 and 2 to produce 0 and for the factorial of 5 is less than 2 of the number of 5 that is 2 with its collocation to get 0 so as long as the calculation of the number of multiples of 5 can be decomposed into 25 125 5*5 In order to get the results also to be carried out in addition to five in order to get a number like 5^n, more than 5 has been circulating to the N=0 code as follows:
public class Solution {public int trailingzeroes (int n) { int count=0; while (n>0) { count+=n/5; N=N/5; } return count; }}
Java-factorial Trailing Zeroes