answersLogoWhite

0


Best Answer
  • #include

    void main()

    {

    int n1,n2,n3,i,gcd,s;

    printf("enter number n1,n2,n3:-");

    scanf("%d %d %d",&n1,&n2,&n3);

    if(n1

    s=n1;

    else if(n2

    s=n2;

    else

    s=n3;

    for(i=1;i<=s;i++)

    {

    if(n1%i==0&&n2%i==0&&n3%i==0)

    gcd=i;

    }

    printf("gcd=%d",gcd);

    }

GCD OF THREE NUBER USING FUNCTION.
  • #include

    void main()

    {

    int gcd(int x,int y);

    int a,b,c;

    printf("enter two number");

    scanf("%d %d",&a,&b);

    c=gcd(a,b);

    printf("%d",c);

    }

    int gcd(int x,int y)

    {

    int temp1,temp2,temp;

    temp1=(x>=0)?x:-x;

    temp2=(y>=0)?y:-y;

    if(temp1

    {

    temp=temp1;

    temp1=temp2;

    temp2=temp;

    }

    while(temp2>0)

    {

    temp=temp1%temp2;

    temp1=temp2;

    temp2=temp;

    }

    return (temp1);

    }

LCM AND GCD OF TWO NUMBER.

#include

void main()

{

int n1,n2,i,lcm,gcd,min=0,f;

printf("enter number :-");

scanf("%d %d",&n1,&n2);

if(n1

min=n1;

else

min=n2;

for(i=1;i<=min;i++)

{

if(n1%i==0&&n2%i==0)

gcd=i;

}

f=n1*n2;

lcm=f/gcd;

printf("gcd=%d",gcd);

printf("\nlcm=%d",lcm);

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

1mo ago

To find the greatest common divisor (gcd) of two numbers, you can use methods like prime factorization, Euclidean algorithm, or a GCD calculator. To find the least common multiple (LCM) of two numbers, you can use prime factorization, multiples method, or an LCM calculator.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you find the gcd and LCM of given numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you find the numbers given the gcd and lcm?

if the gcd and lcm are given and one of the numbers are also given,multiply the gcd and lcm and divide them by the given number


What is the gcd and LCM of 750?

You need at least two numbers to find either of those.


The gcd of 72 and 252 is 36 find their LCM?

If you have two numbers m and n and their gcd (or gcf), g then their LCM = m*n/g so LCM = 72*252/36 = 2*252 = 504.


Compute the gcd and LCM of two numbers?

If you have the gcd or the LCM of two numbers, call them a and b, you can use the relationship that gcd(a,b) = (a multiplied by b) divided by LCM (a,b) where LCM or gcd (a,b) means the LCM or a and b. This means the gcd multiplied by the LCM is the same as the product of two numbers. Let's assume you have neither. There are several ways to do this. One way to approach both problems at once is to factor each number into primes. You can use these prime factorizations to find both the LCM and gcd To compute the Greatest common divisor, list the common prime factors and raise each to the least multiplicities that occurs among the several whole numbers. To compute the least common multiple, list all prime factors and raise each to the greatest multiplicities that occurs among the several whole numbers.


Shell program for gcd of three given numbers?

write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html


The product of 2 numbers is 1600 and their gcd is 2 what is the LCM?

800


How do you write a C program to find the GCD and LCM of two numbers using a switch statement?

The following function will return the GCD or LCM of two arguments (x and y) depending on the value of the fct argument (GCD or LCM). enum FUNC {GCD, LCM}; int gcd_or_lcm(FUNC fct, int x, int y) { int result = 0; switch (fct) { case (GCD): result = gcd (x, y); break; case (LCM): result = lcm (x, y); break; } return result; }


Find the GCD and LCM for 351 and 273?

The GCF is 39 The LCM is 2457.


What is the GCM of 5 6 and 7?

I think you mean either the GCD or the LCM? Not sure which since they are relatively prime, the LCM will the the product of the three numbers and the GCD is 1


What is the LCM of 42 and 7?

The LCM of any two numbers can be found with the following formula:LCM(a,b) = (ab) / GCD (a,b).The GCD of two numbers is best found with the Euclidean algorithm which is as follows:GCD(a,b) =a --if b = 0or GCD(b, a mod b) otherwiseIn the example given we have GCD(42,7) = GCD(7, 0) = 7Then LCM(42,7) = (7*42)/7 = 42Note: mod is the operation of dividing one number by another and taking the remainder. e.g. 7 mod 4 = 3, 12 mod 6 = 0.


If the GCD of two number is 16 and product of the number is 3584 find the LCM?

If we multiply the gcd and the LCM, we get the numbers.Call the numbers a and b. So 16(LCM)=ab3584=ab let's all the LCM, x 16x=a(3584/a)using the information above.x= 1/16(3584)or x=224 So the LCM is 224 we can just say the (gcd)LCM=ab=3584, so just divide 3584 by 16.


What is GCD and LCM of 195 and 351?

GCD = 39 LCM = 1,755