- HCF Stands For Higest Common Factor.
- HCF is also Known as GCD (Greatest Common Divisor).
- HCF of Two Number is defined as the Largest Number that Divides Both Numbers Completely with Remainder Zero.
- LCM Stands For Lowest Common Multiple.
- LCM of two Numbers Defined as the Smallest Number that is Multiple of both Numbers.
int num1 , num2 , lcm , gcd , remainder , numerator , denominator ;
printf( "Enter two numbers\n");
scanf(" %d%d " , &num1 , &num2 );
if (num1 > num2)
numerator = num2 ;
denominator = num1 ;
remainder = num1 % num2;
while ( remainder != 0)
numerator = denominator;
denominator = remainder;
remainder = numerator % denominator;
gcd = denominator;
lcm = (num1 * num2 ) / gcd;
printf("GCD of %d and %d =%d\n" , num1, num2, gcd);
printf(" LCM of %d and %d= %d\n" , num1, num2, lcm);
Enter two numbers
GCD of 5 and 15 = 5
LCM of 5 and 15 = 15