Created
April 17, 2020 14:49
-
-
Save wiccy46/50d82c7b517e11f4040be95a38c4ca5d to your computer and use it in GitHub Desktop.
[lcm] Lowest Common Multiple #python #math
This file contains hidden or 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 math import gcd # Python versions 3.5 and above | |
#from fractions import gcd # Python versions below 3.5 | |
from functools import reduce # Python version 3.x | |
def lcm(denominators): | |
return reduce(lambda a,b: a*b // gcd(a,b), denominators) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment