Skip to content

Instantly share code, notes, and snippets.

@rajatdiptabiswas
Created October 22, 2017 10:25
Show Gist options
  • Save rajatdiptabiswas/3871545a90ba2746a216c213f7608118 to your computer and use it in GitHub Desktop.
Save rajatdiptabiswas/3871545a90ba2746a216c213f7608118 to your computer and use it in GitHub Desktop.
Euclid's Algorithm to find GCD of two numbers
#!/usr/bin/env python3
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
a = int(input("a = "))
b = int(input("b = "))
print("The GCD of {} and {} is {}".format(a, b, gcd(a, b)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment