← Back to challenges

LCM of Two Numbers

PythonHardmathnumbers

Instructions

Write a function that returns the least common multiple (LCM) of two integers.

Examples

lcm(9, 18) ➞ 18

lcm(8, 5) ➞ 40

lcm(17, 11) ➞ 187

Notes

  • Both values will be positive.
  • The LCM is the smallest integer that is divisible by both numbers such that the remainder is zero.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.