Program to Find LCM.

Definition:- The smallest positive number that is a multiple of two or more numbers.

Example: the Least Common Multiple of 3 and 5 is 15, because 15 is a multiple of 3 and also a multiple of 5. Other common multiples include 30 and 45, etc, but they are not the smallest (least).


(Also called Lowest Common Multiple)


Program:-

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
    int n1, n2, max;

    cout << "Enter two numbers: ";
    cin >> n1 >> n2;

    // maximum value between n1 and n2 is stored in max
    max = (n1 > n2) ? n1 : n2;

    do
    {
if (max % n1 == 0 && max % n2 == 0)
{
   cout << "LCM = " << max;
   break;
}
else
   ++max;
    } while (1);

getch();
}

Output:-
Output of the Program to Find LCM.
Output!!!!!!!!!

Post a Comment

0 Comments