Created
July 23, 2019 12:04
-
-
Save raheemazeezabiodun/cf6be89f5b59c1670ecadf28f64634a6 to your computer and use it in GitHub Desktop.
Computing greatest common divisor
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 slow_gcd(arg1,arg2): | |
gcd = 0 | |
for num in range(1, arg1 + arg2+ 1): | |
if (arg1 % num == 0) and (arg2 %num == 0): | |
gcd = num | |
return gcd | |
def fast_gcd(arg1,arg2): | |
if arg2 == 0: | |
return arg1 | |
arg1_prime = arg1 % arg2 | |
return fast_gcd(arg2, arg1_prime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment