CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
using namespace std;
int main() {
int a,b=2,c=1,fact[c],d=0;
cin>>a;
int a2=a;
for(b;b<=a;b++){
while(a%b==0){
cout<<a<<" "<<b<<endl;
fact[d]=b,a/=b,c++,d++;
}
}b=0,d=1;
cout<<a<<endl<<a2<<" = ";
while(b<c-1){
while(fact[b]==fact[b+1]){
b++,d++;
}if(d>1){
cout<<"("<<fact[b]<<"^"<<d<<")";
}else{
cout<<fact[b];
}if(b<c-2){
cout<<"*";
}b++,d=1;
}
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run