Editor settings

General settings

Save settings

Learn to program with Python

Find least common multiple #

Write a function that takes two integers as input and calculates the least common multiple (LCM) of all the numbers between those two integers, inclusive. The LCM is the smallest positive integer that is divisible by all the numbers in the given range.

For example, if the input is the numbers 1 and 5, the least common multiple of all numbers 1, 2, 3, 4, and 5 is 60.


Tests #

  • find_lcm([1, 5]) should return 60
  • find_lcm([5, 1]) should return 60
  • find_lcm([3, 10]) should return 2520
  • find_lcm([1, 1]) should return 1
  • find_lcm([2, 7]) should return 420
Output will be displayed here