JavaScript Program to find LCM

You are Here:

What is Least Common Multiple?

A smallest common multiple of two or more integers.

In general, Least Common Multiple (LCM) is otherwise called as Lowest Common Multiple (LCM) or Smallest Common Multiple (SCM)

Tips: It is recommended to use our online LCM calculator for better understanding.

Examples

The following table provides few examples of LCM of the given numbers.

NumbersLCM
4, 1020
6, 530
15, 30 , 4590

LCM of Two Numbers

n the following example, we will find the LCM of the given two numbers (45, 90).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <h1>JS LCM</h1> <script> var num1 = 45; var num2 = 90; max = (num1 > num2) ? num1 : num2; while(1) { if( max % num1 == 0 && max % num2 == 0 ) { document.write("LCM of "+num1+" and "+num2+": " +max); break; } ++max; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author