Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int prim(int x)
- {
- int i;
- if(x==1)
- return 0;
- else
- for(i=2;i*i<=x;i++)
- if(x%i==0)
- return 0;
- return 1;
- }
- int main()
- {
- int n, d=2, p=1, e;
- cin>>n;
- if(prim(n)==1)
- {
- cout<<n;
- return 0;
- }
- while(d*d<=n)
- { e=0;
- while(n%d==0)
- {
- e++;
- n=n/d;
- }
- if(e)
- p=p*d;
- if(d==2)
- d=3;
- else
- d+=2;
- }
- if(n>1)
- p=p*n;
- cout<<p;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement