02-28-2021, 09:11 AM
To get the least common multiple of 2 numbers we can use the lcm function.
In this example we want to know the least common multiple of 36 and 60.
This will print 180 on the screen.
In this example we want to know the least common multiple of 36 and 60.
Quote:num1 = 36
num2 = 60
lcm = num1.lcm(num2)
puts lcm
This will print 180 on the screen.