07-19-2023, 12:36 AM
I know that, in Ruby, you can use the [`Integer#lcm`](
10.lcm(15)
# => 30
Is there an efficient (or built-in to the core or stdlib) way to get the least common multiple of all the integers in a given array? For example:
[5, 3, 10, 2, 20].lcm
# => 60
[To see links please register here]
) method to get the least common multiple of two numbers. For example:10.lcm(15)
# => 30
Is there an efficient (or built-in to the core or stdlib) way to get the least common multiple of all the integers in a given array? For example:
[5, 3, 10, 2, 20].lcm
# => 60