translation
给定一个整型n,返回n!后面的零的个数。注意:你的解决方案应该在log时间复杂度内。
Original
anintegerreturnthenumberofinintime complexity.
Analysis
At first I did not pay much attention to the topic, I thought it was to ask N this number behind 0, although I thought it would not be so simple ... wrote a code to submit, the result WA hint I 5 words should return 1, this I was puzzled, 5 behind Mao 0 na ... Hurry to see the topic ... Oh, it's factorial, that's the problem I've met.
To finally have 0, the factorial process must have 5, if 10, there are two can be divisible by 5 of the number, 10 and 5, and so on ...
Just went to look for a moment before the blog, we can go to see, quite interesting, with a functional language Lisp can find 20000 factorial oh, ^_^
100 of the class really do not come out?
Code
class Solution {public: int trailingZeroes(int n) { intcount0; while1) count5); returncount; }};
Leetcode 172 factorial Trailing zeroes (factorial 0) (*)