#include <iostream> #include <cmath> using namespace std; int main() { int num; cin >> num; bool first = true; for(int factor = 2; factor <= sqrt(num); factor++) { if(num % factor == 0) { int power = 0; while(num % factor == 0) { num /= factor; power++; } if (!first) { cout << " * "; } first = false; if(power == 1) cout << factor; else cout << factor << "^" << power; } } // 如果 num 還不是 1,那麼它本身就是一個質數因數 if (num > 1) { if (!first) { cout << " * "; } cout << num; } cout << endl; return 0; }