Created
April 12, 2018 04:18
-
-
Save kaashmonee/6d9d3066aef73621bd10f088075c0947 to your computer and use it in GitHub Desktop.
finding gcd with the euclidean algorithm
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(a, b): | |
if (a == 1 or b == 1): | |
return 1 | |
elif (a == 0): return b | |
elif (b == 0): return a | |
else: | |
# print(a, b) | |
return gcd(b, a % b) | |
def main(): | |
to_continue = True | |
while (to_continue): | |
a = input("a: ") | |
b = input("b: ") | |
print(gcd(int(a), int(b))) | |
to_continue = True if (input("continue? [Y/n] ") == ("y" or "Y")) else False | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment