Thu Jun 07 2018

LCM

C Programming885 views

File Name: lcm.c

#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

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