bhupixb

Euler totient function

Jun 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. ll Euler(int mod){
  2. ll res = mod;
  3.  
  4. for(int i = 2 ; i * i <= mod ; i++){
  5. if(mod % i == 0){
  6. res = (res * (i - 1))/i;
  7. while(mod % i == 0)
  8. mod /= i;
  9. }
  10. }
  11. if(mod > 1)
  12. res = (res * (mod - 1))/mod;
  13. return res;
  14. }
Add Comment
Please, Sign In to add comment