求因子个数

#include <iostream>
#include <cstdio>
using namespace std;
long long x;
//使用公式
int f1(){
    int s=1;
    long long xx=x,i=2;
    int  count1=0,flg=0;
    while (xx>1)
    {
        if(xx%i==0){
            xx=xx/i;
            count1++;
        }else{
            i++;
            if(count1!=0) s=s*(1+count1);
            count1=0;
        }
    }
    if(count1!=0) s=s*(1+count1);
    return s;
}
int main(){
    while (cin>>x&&x!=0)
    {
        int pp=f1();
        cout<<pp<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/MorrowWind/p/13056585.html