C Program To Find The LCM

Let’s start with lowest common multiple (LCM) program with C language.

C Program To Find The LCM
C Program To Find The LCM

LCM stands for least common multiple. LCM of two or more numbers is the least number that is exactly divisible by each one of the given numbers. You can also refer for c porgram for hcf or gcd.
Here is an example for how we can find lcm of two number:- LCM of 8 and 16 is 32.

Let’s start understand algorithm for LCM program.


ALGORITHM:-

step 1 : Start
step 2 : Enter Any number to calculate LCM
step 3 : Calculate the Lowest Common Factor
step 4 : Stop the Execution

#include<stdio.h>
#include<conio.h>
int lcm(int, int);
int main() {
    int x, y, l;  
    printf("Enter any number two number to calculate the LCM \n");
    scanf("%d%d", &amp;x, &amp;y);
    l = lcm(x, y);
    printf("\nLCM of %d &amp; %d is %d ", x, y, l);
    getch();
}
int lcm(int a, int b) {
    int p;
    for (int i = 1; i <= a; i++) {
        for (int j = 1; j <= b; j++) {
            if (b * i == a * j) {
                 p = b * i;
                 i = i + a;
            }
        }
    }
    return p;
}

OUTPUT:-

Enter Any number two number to calculate the LCM: 
24
16

LCM of 24 and 16 is:  48

C Program To Calculate the LCM of any two number
How to Calculate Lowest commond factor using c
LCM Calculation using C language