Professional Documents
Culture Documents
Example :
HCF and GCD:
1) HCF of 8 and 6.
Factors of 8: 1,2,4,8
Factors of 6: 1,2,3
Minimum number that divides both the numbers is 1 and the maximum number that divides
both the numbers is minimum of both the numbers, here it is 6.
Method 2: Instead of starting from i=1, we can start from i=min and find the first largest factort.
LCM: (Least common multiple)
Multiples of 4: 4,8,12,16,20,24……...
LCM is the first number in the list that is divisible by both the numbers (4 and 5), here it is 20.
Multiples of 4 start from 4 and multiples of 5 start from 5, the common range for 4 and 5 will
start from 5.
From the above the minimum common multiple of A and B will start from the maximum of A
and B.
Minimum number that can be LCM of A and B is maximum of A and B and the maximum
number that can be LCM of A and B is A*B.
Therefore, the LCM of two numbers A and B should be in between (maximum of A, B) and (A*B).
Note:
The product of LCM and GCD will be the product of two numbers.
LCM*GCD = A*B
“continue” key word:
With help of continue key word we can skip a particular iteration.