末尾有多少个0,只要卡有多少个5
,,有一个5,故结果为1.
100/5=20,但结果并不是20,因为
所以计算公式:
class Solution {
public:
int trailingZeroes(int n) {
if(n<5)return 0;
else return n/5+trailingZeroes(n/5);
}
};
末尾有多少个0,只要卡有多少个5
,,有一个5,故结果为1.
100/5=20,但结果并不是20,因为
所以计算公式:
class Solution {
public:
int trailingZeroes(int n) {
if(n<5)return 0;
else return n/5+trailingZeroes(n/5);
}
};