Created
January 7, 2018 17:44
-
-
Save SubhrajitPrusty/1b715375315fcd4c27e6cf9b53787ce2 to your computer and use it in GitHub Desktop.
LCM of a list of numbers
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
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