Least Common Multiple program || for loop || C programming
This is a for loop program in which we will find the Lowest Common Factor(LCM) of N & M till X with the help of the C Programming language.




#include <stdio.h>

int main()
{
    int i, n, m, x;
    printf("Enter 2 number whose LCM is to be found:-\n");
    printf("n = ");
    scanf("%d", &n);
    printf("m = ");
    scanf("%d", &m);
    printf("Enter number till where you want LCM: \n");
    scanf("%d", &x);
    printf("Numbers between 1 to %d that are divisible by %d and %d are: \n", x, n, m);

    for (i = 1; i <= x; i++)
    {
        if (i % n == 0 && i % m == 0)
        {
            printf("%d\n", i);
        }
    }

    return 0;
}

//......Coded by YASH ALAPURIA



#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post