I need to write a program in C++ that determines the biggest power that a number appears to in the prime factorization of an "n" number.

What I did so far:

#include <iostream>

using namespace std;

int main()

{

int n, d = 2, p;

cin >> n;

while(n != 1)

{

p = 0;

while(n % d == 0)

{

p++;

n = n / d;

}

if(p > 0)

{

cout << d << " to the power of " << p << endl;

}

d++;

}

return 0;

}