您的位置:首页 > 其它

1*2*3*......*3000相乘结果的末尾有多少个0?

2012-10-19 13:49 267 查看
[b]  1*2*3*......*3000相乘结果的末尾有多少个0?[/b]

public class CountZeroDemo {
public static void main(String[] args) {
System.out.println(countZero(3000));//748
}
private static int countZero(int n){
int count=0;
int j;
for(int i=1;i<=n;i++){
j=i;
while(j%5==0){
count++;
j/=5;
}
}
return count;
}
}


  结果:748
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: