SHARE
TWEET

Untitled

doinita2002 Nov 14th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int prim(int x)
  4. {
  5.     int i;
  6.     if(x==1)
  7.         return 0;
  8.     else
  9.         for(i=2;i*i<=x;i++)
  10.             if(x%i==0)
  11.             return 0;
  12.         return 1;
  13. }
  14. int main()
  15. {
  16.     int n, d=2, p=1, e;
  17.     cin>>n;
  18.     if(prim(n)==1)
  19.     {
  20.         cout<<n;
  21.         return 0;
  22.     }
  23.     while(d*d<=n)
  24.     { e=0;
  25.     while(n%d==0)
  26.     {
  27.         e++;
  28.         n=n/d;
  29.     }
  30.     if(e)
  31.         p=p*d;
  32.     if(d==2)
  33.         d=3;
  34.     else
  35.         d+=2;
  36. }
  37. if(n>1)
  38.     p=p*n;
  39. cout<<p;
  40. return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top