Modify gcd function

Made gcd function recursive
This commit is contained in:
2019-09-21 09:32:44 +02:00
parent 0da9761f00
commit f3bd132df2
2 changed files with 7 additions and 15 deletions

View File

@ -19,12 +19,10 @@ def is_prime(num):
return 1
def gcd(a, b):
while b != 0:
tmp = b
b = a % b
a = tmp
if b == 0:
return a
return a
return gcd(b, a%b)
def lcm(a, b):
return a * b // gcd(a, b)