Răspuns:
#include <iostream>
using namespace std;
int main(){
int n, d, p, k=0;
cin >> n;
cout << "n = " << n << " = ";
for(d = 2; n != 1; d++){
p = 0;
while (n%d == 0)p++, n/=d;
if(p){
cout << (k != 0 ? " x " : "") << d << '^' << p;
k++;
}
d += (d%2);
}
cout << endl;
return 0;
}