programming-examples/c/Recursion/C Program to find LCM of two numbers by recursion.c
2019-11-15 12:59:38 +01:00

23 lines
441 B
C

#include<stdio.h>
int findlcm(int,int);
int main()
{
int a,b,l;
printf("Enter any two number ");
scanf("%d%d",&a,&b);
if(a>b)
l = findlcm(a,b);
else
l =findlcm(b,a);
printf("LCM of two number is %d",l);
return 0;
}
int findlcm(int a,int b)
{
static int temp = 1;
if(temp % b == 0 && temp % a == 0)
return temp;
temp++;
findlcm(a,b);
return temp;
}