问题描述
给定一个整数x,求x!(阶乘)末尾0的个数。
input: 5
output: 1
基本解题思路:2和5结合可以产生一个0,所以相当于求1——x的序列中包含(2,5)的对数,因为2的个数多于5,所以相当于求因子中5的个数
方法一:暴力求解法,暴力寻找因子5个数
public static int factorOf5(int n){
int count = 0;
while(n % 5 == 0){
count ++;
n /= 5;
}
return count;
}
public static int