Least Common Multiple

Published by persolut in

Given a array of integers, create a function that will find the smallest positive integer that is evenly divisible by all the members of the list. In other words, find the least common multiple (LCM).

Examples

LCM({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }) ➞ 2520

LCM({ 5 }) ➞ 5

LCM({ 5, 7, 11 }) ➞ 385

LCM({ 5, 7, 11, 35, 55, 77 }) ➞ 385

Notes

N/A

Watch a quick demo on how Edabit works.