#include <bits/stdc++.h>
using namespace std;
long long int primefactors(long long int n)
{
cout<<n<<" =";
if(n<0)
{
cout<<" "<<-1<<" x";
n=abs(n);
}
while(n%2==0)
{
if(n==2)
{
cout<<" "<<2<<endl;
}
else
{
cout<<" "<<2<<" x";
}
n=n/2;
}
for(int i=3;i<=sqrt(n);i=i+2)
{
while(n%i==0)
{
if(n==i)
{
cout<<" "<<i<<endl;
}
else
{
cout<<" "<<i<<" x";
}
n=n/i;
}
}
if(n>2)
{
cout<<" "<<n<<endl;
}
}
int main()
{
long long int n;
while(cin>>n)
{
if(n==0)
{
break;
}
primefactors(n);
}
return 0;
}
0 comments:
Post a Comment