#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);cin.tie(0);
int prime[26]={
2,3,5,7,11,13,17,19,23,29, 31,37,41,43,47,53,59,61,67,71, 73,79,83,89,97,101
};
int n;
while(cin>>n){
int x[26]={0};
vector<int>other;
for(int i=2;i<=n;i++){
int t=i;
for(int j=0;j<26;j++){
if(t%prime[j]==0){
while(t%prime[j]==0){
x[j]++;
t/=prime[j];
}
}
}
if(t!=1)other.push_back(t);
}
sort(other.begin(),other.end());
cout<<n<<"! = ";
int c=0;
for(int i=0;i<26;i++){
if(x[i]!=0){
if(c)cout<<" * ";
cout<<prime[i]<<"^"<<x[i];
c=1;
}
}
for(int i=0;i<other.size();i++){
cout<<" * "<<other[i]<<"^";
int cnt=1;
while(other[i]==other[i+1]){
cnt++;
i++;
}
cout<<cnt;
}
cout<<'\n';
}
return 0;
}
自己測試都是對的