Code
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, i;
cout<<"Please input an integer then press ENTER : ";cin>>n;
while(n%2 == 0)
{
cout<<2<<" ";
n = n/2;
}
for( i =3; i<=n; i=i+2)
{
while(n%i == 0)
{
cout<<i<<" ";
n=n/i;
}
}
if(n>2)
{
cout<<n<<" ";
}
return 0;
}
No comments:
Post a Comment