descompunea in factori primi

Realizati un program care descompune in factori primi un numar n citit de la tastatura

#include <iostream>

using namespace std;

int main()
{

int n,d=2,p;
cout<<“n=”;cin>>n;
while(n>1)
{
p=0;
while(n%d==0)
{
p=p+1;
n=n/d;
}
if(p) cout<<d<<” la puterea “<<p<<endl;
d=d+1;
}

return 0;
}