LCM

#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

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!