#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,m,a,b;
int gcd,lcm;
printf("\nEnter the two numbers:");
printf("\n a: ");
scanf("%d",&a);
printf("\n b: ");
scanf("%d",&b);
m=a;
n=b;
while(m!=n)
{
if(m>n)
{
m=m-n;
}
else
{
n=n-m;
}
}
gcd=m;
lcm=(a*b)/gcd;
printf("lcm of %d and %d is = %d",a,b,lcm);
printf("\ngcd of %d and %d is = %d",a,b,gcd);
}
Comments
Post a Comment