6.HCF and LCM

HCF : (Using Euclidean Algorithm)

GCD of two numbers is the largest number that divides both of them. GCD of 15 and 20 is 5

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

LCM:

LCM (Least Common Multiple) of two numbers is the smallest number which can be divided by both numbers. LCM of 15 and 20 is 60

LCM(a,b) = a*b / gcd(a,b)

Ax - By = 0

Smallest value of x and y can be found by LCM/x , LCM/y

Last updated