整數因子分解

 

#include<bits/stdc++.h>
using namespace std;
//整數因子分解
int total;				//定義爲全局變量
void solve(int n)
{
	if (n==1) total++;		//獲得一個分解
	else for (int i=2; i<=n; i++)
		if (n%i==0) solve(n/i);
}
int main()
{
int n;
while( scanf("%d",&n)!=EOF)
{
	total = 0;
	solve(n);
	printf("%d\n",total);
}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章