The number of divisors(约数) about Humble Numbers
分析:
这道题其实是叫我们求一个数的质因数2, 3, 5, 7的个数,所以我们可以根据公式,求出每个因子数量,然后进行乘积。
公式如下:
代码:
#include <iostream>
using namespace std;
int main(){
long long n = 1;
int arr[] = {
2, 3, 5, 7 };
while (cin >> n && n != 0){
int num = 1;
for (int i = 0; i < 4; i++){
int cout = 0;
for (; n % arr[i] == 0; n /= arr[i])cout++;
num *= cout + 1;
}
cout << num << endl;
}
}