GCD and LCM
Law:
(num1 *
num2) = gcd(num1,num2) * lcm(num1,num2);
STL C++:
__gcd(
num1, num2);
GCD:
Int
gcd(int a, int b)
{
if(a==0)
{
return
b;
}
else
{
return
gcd(b%a,a);
}
}
LCM:
mx = max( num1,num2);
while(1)
{
If(mx%
num1 = =0 && mx%num2==0)
{
Lcm
=mx;
Break;
}
else
{
mx++;
}
}