SHARE
TWEET

Untitled

a guest May 16th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def gcd(a,b):
  2.     if a == 0:
  3.         return (b,0,1)
  4.     else:
  5.         g, y, x = gcd(b % a ,a)
  6.         return (g, x-(b//a)*y,y)
  7.  
  8. def mod_inverse(a,m):
  9.     g, x, y = gcd(a, m)
  10.     if g != 1:
  11.         raise Exception('Modular error')
  12.     else:
  13.         return x % m
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