Skip to content

Instantly share code, notes, and snippets.

@wiccy46
Created April 17, 2020 14:49
Show Gist options
  • Save wiccy46/50d82c7b517e11f4040be95a38c4ca5d to your computer and use it in GitHub Desktop.
Save wiccy46/50d82c7b517e11f4040be95a38c4ca5d to your computer and use it in GitHub Desktop.
[lcm] Lowest Common Multiple #python #math
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