Problem Statement for LCM:
Enter Two digits by a user and get its LCM
Answer:
#include
#include
void main()
{
int x,y,i,j;
clrscr();
printf("Enter Two Digits");
scanf("d",&x,&y);
for(i=1;i<=x;i++)
{
for(j=1;j<=y;j++)
{
if(y*i==x*j)
{
printf("LCM is %d\n",y*i);
i=i+x;
}
}
}
getch();
}
OR
there will be another easy way to solve it...
Answer:
#include
#include
void main()
{
int x,y,i,;
clrscr();
printf("Enter Two Digits = ");
scanf("d",&x,&y);
for(i=1;i<=x*y;i++) {
if(i%x==0&&i%y==0)
{
printf(LCM is %d",i);
break;
}
}
getch();
}
lcm(a,b,c,d) = lcm(lcm(a,b,c),d) = lcm(lcm(a,b),lcm(c,d))
You cannot find the LCM of one number. There must be two numbers to compare, because the C means common.
If C is co-prime with 6 and with 7, then LCM(6, 7, C) = 42*C If not, the answer depends on the value of C.
That would depend on the value of C.
That depends on the values of A, B and C.
The C stands for Common.
If they have no common factors other than 1, the LCM is their product.
Find the LCM of the first two numbers and then find the LCM of that number and the third one. That answer will be the LCM of all three.
#include<stdio.h> main() { int a,b,i,lcm,gcf; printf("\n Enter two numbers"); scanf("%d%d",&a,&b); for(i=0;i<=a;i++) { if((b%i==0)&&(a%i==0)) { gcf=i; } } lcm=a*b/gcf; printf("\n GCF is %d and LCM is %d",gcf,lcm); }
You need at least two numbers to find an LCM.
Two or more numbers are needed to find the LCM
You need at least two numbers to find an LCM.