day1/exercise/gcd_another.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Sat, 19 Jun 2010 01:27:20 -0400
branchscipy2010
changeset 409 4442da6bf693
parent 64 333092b68926
permissions -rw-r--r--
ENH: Minor cleanup. Also added slide to introduce IPython's %timeit and %time.

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)