Skip to content

Instantly share code, notes, and snippets.

@hzshang
Created June 8, 2018 01:29
Show Gist options
  • Save hzshang/4e4461796a4309375c1be116a6dde46a to your computer and use it in GitHub Desktop.
Save hzshang/4e4461796a4309375c1be116a6dde46a to your computer and use it in GitHub Desktop.
def extend_gcd(a,b):
if b==0:
return a,1,0
else:
g,s,t=extend_gcd(b,a%b)
return g,t,s-a/b*t
def reverse(a,N):
return extend_gcd(a,N)[1]
print reverse(5,7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment