Computer Science, asked by sangeethaj2017, 1 month ago

C Program to find LCM of two numbers using Recursion

Answers

Answered by dreamrob
1

Program:

#include<stdio.h>

#include<conio.h>

int lcm(int a , int b)

{

static int m = 0;

m = m + b;

if(m % a == 0 && m % b == 0)

{

 return m;

}

return lcm(a , b);

}

int main()

{

int x , y;

printf("Enter First Number : ");

scanf("%d" , &x);

printf("Enter Seconf Number : ");

scanf("%d" , &y);

printf("LCM of %d and %d = %d" , x , y , lcm(x , y));

return 0;

}

Output:

Enter First Number : 36

Enter Seconf Number : 20

LCM of 36 and 20 = 180

Similar questions