C Program to Find LCM
This is the C Program to find lcm of two numbers
LCM=Product of two Numbers/GCD
In arithmetic and number theory, the least common multiple (also called the lowest common multiple or smallest common multiple) of two integers a and b, usually denoted by LCM(a, b), is the smallest positive integer that is divisible by both a and b.
#include<stdio.h>
int gcd1;
main()
{
int num1,num2;
printf("Enter Two Numbers");
scanf("%d%d",&num1,&num2);
findbig(num1,num2);
}
int findbig(int num1,int num2)
{
int pro;
pro=num1*num2;
if (num1>num2)
return gcd(num1,num2,pro);
else
return gcd(num2,num1,pro);
}
int gcd(int big,int small,int pro)
{
int rem,lcm;
rem=small%big;
printf("nThe Remainder is %dn",rem);
if (rem==0)
{
printf("n THE GCD is %dn",big);
lcm=pro/big;
printf("n The LCM is %dn",lcm);
}
else
return gcd(rem,big,pro);
}
Recent Comments