LCM of More Than Three Numbers

Published by Deep Xavier in

Create a function that takes an array of more than three numbers and returns the Least Common Multiple (LCM).

Examples

lcmOfArray([5, 4, 6, 46, 54, 12, 13, 17]) ➞ 2744820

lcmOfArray([46, 54, 466, 544]) ➞ 78712992

lcmOfArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ➞ 2520

lcmOfArray([13, 6, 17, 18, 19, 20, 37]) ➞ 27965340

Notes

The LCM of an array of numbers is the smallest positive number that is divisible by each of the numbers in the array.

Watch a quick demo on how Edabit works.