这道题用到了数学,可惜我不会这个公式,只能cv了
package com.company.test.阶乘末尾0的数量;
/**
* @author xienl
* @description 阶乘末尾0的数量
* @date 2022/8/26
*/
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
}
public long thenumberof0 (long n) {
// write code here
long ans = 0;
long d = 5;
while (n >= d){
ans += n/d;
d = d * 5;
}
return ans;
}
}