阶乘尾数零的个数100!的尾数有多少个0?

    阶乘产生0

public class 阶乘尾数0的个数 {
    public static void main(String[] args) {
        int a;
        int count = 0;
        for (a = 5; a <= 100; a += 5) //循环从5开始,以5的倍数为步长,考察整数
        {
            count++; //若为5的倍数,计数器加1
            if (a%25==0) {
                count++;
            };
                //若为25的倍数,计数器再加1
        }
         System.out.println("The number of 0 in the end of 100! is:"+count);
    }

}

的条件:若为5的倍数,则含有一个0,若为25 的倍数则含有2个0。

发布了64 篇原创文章 · 获赞 47 · 访问量 9527

猜你喜欢

转载自blog.csdn.net/weixin_42194284/article/details/102808617