Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Phi(int n)
- {
- int d,p;
- double phi;
- phi = n;
- d = 2;
- while(n != 1)
- {
- p = 0;
- while (n % d ==0)
- {
- p++;
- n/=d;
- }
- if(p > 0) phi *= (d-1) * 1./d;
- if(d * d < n) d ++;
- else d = n;
- }
- return int(phi);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement