QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Find LCM (Least Common Multiple)

Calculates the least common multiple (LCM) of two numbers.

  • math
  • lcm
  • gcd

Code

def lcm(a, b):
    return abs(a * b) // gcd(a, b)

Usage

lcm(12, 15) # Returns: 60
lcm(7, 5) # Returns: 35