The below formula can be used to get the [LCM][1] of two numbers. <sup>See **Reduction by the greatest common divisor** section in Wikipedia</sup>

                   a * b
    lcm(a, b) = ―――――――――――
                 gcd(a, b)


[GCD][2] can be calculated by using the [Euclidean Algorithm][3]<sup>See **Using Euclid's algorithm** section in Wikipedia</sup>.

    gcd(a, b) = gcd(b, a % b)

Using these two formulas, the LCM can be calculated as follow

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

    console.time('new');

    function gcd(a, b) {
        while (b !== 0) {
            var temp = a;
            a = b;
            b = temp % b;

            // Can be written in ES6 as
            // [a, b] = [b, a % b];
        }

        return a;
    }

    function lcm(a, b) {
        return a * b / gcd(a, b);
    }
    var range = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
    console.log(range.reduce(lcm, 1));
    console.timeEnd('new');

<!-- end snippet -->

This is very efficient than using `while` and `for`, see this [**JsFiddle**][4] demo.

**Note:** This answer is inspired by [this][5] and [this][6] posts.


  [1]: https://en.wikipedia.org/wiki/Least_common_multiple
  [2]: https://en.wikipedia.org/wiki/Greatest_common_divisor
  [3]: https://en.wikipedia.org/wiki/Euclidean_algorithm
  [4]: https://jsfiddle.net/u7xj8hrc/
  [5]: http://stackoverflow.com/a/2127114/2025923
  [6]: http://stackoverflow.com/a/18944210/2025923