Answers for "how lcm works"

C++
0

LCM code

#include<iostream>
using namespace std;
int gcd(int a,int b)
{
    if(a%b==0)
    return b;
    else
    gcd(b,a%b);
}
int main()
{
int a,b;
cin>>a>>b;
int res = gcd(a,b);
cout<<"HCF : "<<res<<endl;
cout<<"LCM :"<<(a*b)/res;
return 0;
}
Posted by: Guest on October-20-2021

Browse Popular Code Answers by Language