Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

using namespace std;

int main()
{
int n1,n2,l;
cout<<"Enter the value of n1 and n2 :"<<endl;
cin>>n1>>n2;

l=(n1>n2)?n1:n2;

while(true)
{
if(l%n1==0&&l%n2==0)
{
cout<<"LCM of "<<n1<<" and "<<n2<<" is = "<<l<<endl;
break;
}
++l;
}
}

You might also like