1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
using namespace std;
void get_prime_factors(int);
int main(){
int num;
cout<<"Enter a number: ";
cin>>num;
cout<<"\nSolution: "<<endl;
get_prime_factors(num);
system("PAUSE");
return 0;
}
void get_prime_factors(int num){
int dividers[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int size=24;
for(int i=size;i>=2;i--){
loop:
if((num%i==0)&&i>1){
num/=i;
cout<<num/i<<"*";
goto loop;
}
else if(i==1){
cout<<"*1";
break;
}
else continue;
}
}
|