Answers for "LCM of n numbers in C++"

C++
0

LCM and HCF using c++

#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