计算1000!包含多少个0?

来源:互联网 发布:相片排版软件 编辑:程序博客网 时间:2024/04/30 01:37

/*

思路就是求5 的个数

*/

public class Test1000 {

public static void main(String[] args){
System.out.println(sum(1000));

}

public  static int sum(int n){
int count = 0;
while(n / 5 !=0){
count +=n / 5;
n = n / 5;
}
return count;
}

}
0 0
原创粉丝点击