Skip to content

Instantly share code, notes, and snippets.

@SubhrajitPrusty
Created January 7, 2018 17:44
Show Gist options
  • Save SubhrajitPrusty/1b715375315fcd4c27e6cf9b53787ce2 to your computer and use it in GitHub Desktop.
Save SubhrajitPrusty/1b715375315fcd4c27e6cf9b53787ce2 to your computer and use it in GitHub Desktop.
LCM of a list of numbers
from functools import reduce
def gcd(a,b):
if b%a == 0:
return a
else:
return gcd(b%a, a)
def lcm(*args):
def lcm(a,b):
return a*b // gcd(a,b)
return reduce(lcm, args, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment