Wisdom Materials
Home
About Us
Our Clients
Careers
Services
Education
Jobs
News
Business
Health
Astrology
Entertainment
RealEstate
Devotion
Contact Us
C Programs
/ LCM C Program
Program
Copy text
#include
int gcd(int , int ); int lcm(int , int) ; int gcd(int a, int b) { if (a == 0) return b; while (b!= 0) { if (a > b) a = a - b; else b = b - a; } return a; } int lcm(int a, int b) { return (a*b)/gcd(a, b); } void main() { int a,b; printf("Enter 2 of Numbers\n"); scanf("%d%d",&a,&b); printf("LCM of %d and %d is %d ", a, b, lcm(a, b)); }
Input
Enter 2 of Numbers: 10 15
Output
LCM of 10 and 15 is 30
Home
Back