29 lines
535 B
C
29 lines
535 B
C
|
/*
|
||
|
* C Program to Find LCM of a Number using Recursion
|
||
|
*/
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int lcm(int, int);
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int a, b, result;
|
||
|
int prime[100];
|
||
|
printf("Enter two numbers: ");
|
||
|
scanf("%d%d", &a, &b);
|
||
|
result = lcm(a, b);
|
||
|
printf("The LCM of %d and %d is %d\n", a, b, result);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int lcm(int a, int b)
|
||
|
{
|
||
|
static int common = 1;
|
||
|
if (common % a == 0 && common % b == 0)
|
||
|
{
|
||
|
return common;
|
||
|
}
|
||
|
common++;
|
||
|
lcm(a, b);
|
||
|
return common;
|
||
|
}
|