summaryrefslogtreecommitdiff
path: root/day1/exercise/gcd_another.py
blob: fe9e6a6c51475e380950d460266ca969ac04f38c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
def gcd(a, b):
  if a - b == 0:
    return b
  if a > b:
    return gcd(b, a-b)
  else:
    return gcd(b, b-a)

def lcm(a, b):
    return (a * b) / gcd(a, b)

print lcm(21, 14)