C Programming

LCM

Learn C programming for find lowest common multiple of two positive interger

6/7/2018
0 views
lcm.cC
#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
C programmingC codingLowest common multiplelcm

Loading comments...

Related Examples

Deliver breaking news, insightful commentary, and exclusive reports.

Targeting readers who rely on our platform to stay ahead of the curve.

Contact Us: benzingaheadlines@gmail.com