Get Website Learn Coding Tech Story

C Programming Examples

#include<stdio.h>

int common_divisor(int, int);

int main() {
	int a, b, gcd, lcm;
	printf("Enter two positive number to find Lowest Common Multiple:\n");
	scanf("%d %d",&a, &b);
	gcd = common_divisor(a, b);
	lcm = (a * b) / gcd;
	printf("Lcm of two number is: %d\n",lcm);
	return 0;
}

/* Recursive function */
int common_divisor(int x, int y) {
	if(y == 0)
		return x;
	else
		/* Call the common_divisor function inside in it */
		common_divisor(y, x % y);
}


          /****** Output ******/
          

Enter two positive number to find Lowest Common Multiple:

30

20

Lcm of two number is: 60

Learn more about Lowest Common Multiple