# LCM – Least Common Multiple

Multiple of 3 is
3×1=3
3×2=6
3×3=9
3×4=12
3×5=15
3×6=18
3×7=21
3×8=24
3×9=27
3×10=30

Multiple of 4 is
4×1=4
4×2=8
4×3=12
4×4=16
4×5=20
4×6=24
4×7=28
4×8=32
4×9=36
4×10=40

Here in 3 and 4 mutilples common is 12
and it is only one value and so it is the lowest also then but if there were some more values than result could be something changed.

So here LCM=12
Here I implemented the code
applied this formula
lcm(a,b)=a*b/gcd(a,b);

code goes here :

#include<stdio.h>
int main()
{
int a,b,x,gcd,lcm;
scanf("%d %d",&a,&b);

if(a<b)//it is not possible for gcd to be greater than the lowest value
{
x=a;
}
else
{
x=b;
}
for( ;x>=1;x--){ //here i haven't initialized the value of x as x is first at outside
if(a%x==0 && b%x==0){
gcd=x;
break; //here i have used break as if it is not here then when the division will happen it will run the loop till 1 so answer will be always 1
}
}

printf("GCD is %d\n",gcd);
lcm=a*b/gcd;
printf("LCM is %d\n",lcm);

return 0;
}

It would be a great help, if you support by sharing :)
Author: zakilive