Skip to content

Instantly share code, notes, and snippets.

@iamprayush
Created August 21, 2020 05:43
Show Gist options
  • Save iamprayush/de94e9c1d8cc5c29d9469ac1ec33767c to your computer and use it in GitHub Desktop.
Save iamprayush/de94e9c1d8cc5c29d9469ac1ec33767c to your computer and use it in GitHub Desktop.
Euclidean GCD
def gcd_euclidean(x, y):
if x < y:
x, y = y, x
if y == 0:
return x
return gcd_euclidean(y, x % y)
def gcd_euclidean_iter(x, y):
if x < y: x, y = y, x
while y:
x, y = y, x%y
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment