← Back to challenges

LCM of More Than Three Numbers

JavaScriptHardnumbersmath

Instructions

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

Examples

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

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

lcmOfArray([44, 64, 12, 17, 65]) ➞ 2333760

Notes

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

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.