LCM of two integer

#include <stdio.h>
#include <stdlib.h>

void main()
{
    int a,b,L,n,i,j;
    printf("Enter two numbers : ");
    scanf("%d %d",&a,&b);
    for(L=(a>b?a:b);L<=(a*b);L+=(a>b?a:b))
    {
        if(L%a==0 && L%b==0)
        break;
    }
    H=(a*b)/L;
    printf("The LCM is %d\n",L);
    printf("The HCF is %d",H);
}

Comments

Popular posts from this blog

Basic calculator using C programming

Factorial of consecutively 5 numbers(input)

Square Root of a number without using math.h function