只需数字中有多少个因子“5”就可以了,因为因子“2”的数量肯定要比“5”的数量多。
public
class Solution {
public int trailingZeroes(int n) {
int r = 0 ;
while (n > 0 ) {
n /= 5 ;
r += n;
}
return r;
}
}
public int trailingZeroes(int n) {
int r = 0 ;
while (n > 0 ) {
n /= 5 ;
r += n;
}
return r;
}
}