标签:
Factorial Trailing Zeroes
问题:
Given an integer n, return the number of trailing zeroes in n!.
Note: Your solution should be in logarithmic time complexity.
思路:
知道思路,完全想不明白啊
别人代码:
public class Solution { public int trailingZeroes(int n) { if(n <= 0) return 0; int k = 0; while(n > 0) { k += n/5; n /= 5; } return k; } }
为什么??
别人解释:看完之后才恍然大悟,大彻大悟中。。。。
标签:
原文地址:http://www.cnblogs.com/sunshisonghit/p/4387300.html