I have a program that will find prime factors of any input number
Code:#include <iostream> using namespace std; int main() { int n; cout << "Enter the number to factor:" << endl; cin >> n; int k=2; cout << "The prime factors of " << n << " are: " << endl; while (n > k*k) { if ((n%k)==0) { n=(n/k); cout << k << " "; } else {k=k+1; } } cout << n << " "; }
Now, say I put in 567 as the number to factor, the output would be 3 3 3 3 7
However, if I want to switch that output to the format 3^4 7, I'm not really sure how to go about doing that.
Any help I can get would be great
Thanks



LinkBack URL
About LinkBacks



