Created
August 21, 2020 05:43
-
-
Save iamprayush/de94e9c1d8cc5c29d9469ac1ec33767c to your computer and use it in GitHub Desktop.
Euclidean GCD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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