Answers for "HCF and LCM"

C++
0

LCM and HCF 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
0

lcm hcf relation

PRODUCT(A,B) = HCF(A,B) * LCM(A,B)
Posted by: Guest on January-29-2021

Browse Popular Code Answers by Language