N的阶乘后有多少0

来源:互联网 发布:销售记录软件 编辑:程序博客网 时间:2024/05/17 03:43
 阶乘中的0的个数和因数中有多少个因子5相等。



Z = N/5 + N /(5*5) + N/(5*5*5).....直到N/(5的K次方)等于0


 int zeroCount(int n)

 {
     int count=0;
     while(n)
     {
         count+=n/5;
         n/5;
    }
    return count;
 }
0 0