计算n!中质因子p的个数

#include <stdio.h>

int cal(int n,int p)
{//计算n!中有多少个质因子p
    int ans=0;
    while(n!=0)
    {
        ans+=n/p;
        n/=p;
    }
    return ans;
}

发布了54 篇原创文章 · 获赞 1 · 访问量 516

猜你喜欢

转载自blog.csdn.net/weixin_43370733/article/details/103789385
今日推荐