answersLogoWhite

0

// recursive algorithm to return gcd using Euclid's Algorithm

int gcd (int a, int b) {

if (a<0) a= -a;

if (b<0) b= -b;

if (a<b) { int tmp; tmp= a; a= b; b= tmp; }

if (b == 0) return a;

return gcd (b, a%b);

}

// LCM using gcd

int LCM (int a, int b) {

int t;

t = a*b;

if (t<0) t=-t;

return t / gcd (a, b);

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

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


Define flowchart and draw flowchart for GCD of two numbers?

pictorial representation of a program is called a flowchart


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


How do you find the GCD of two numbers?

use slide


What is the GCD of 336?

You need at least two numbers to find a GCF.


What is the gcd of 12?

You need at least two numbers to find a GCF.


What is pseudo code for GCD of two numbers?

public class GCD { public static void main(String[] args) { //Example how to use this method System.out.println(GCD(15,50)); } //find the greatest common divisor of two numbers public static int GCD(int a, int b){ if (b == 0) return a; return GCD(b, a % b); } } Hope this help to solve you problem.


What is the GCD of 1029?

You need at least two numbers to find something in common.


What is the gcd of 24?

You need at least two numbers to find something in common.


What is 26 GCD?

You need at least two numbers to find something in common.


What is the greatest common divisor of 2233 and 25193?

The greatest common divisor (GCD) of two numbers is the largest positive integer that divides both numbers without a remainder. To find the GCD of 2233 and 25193, you can use the Euclidean algorithm. By repeatedly applying the algorithm, you will find that the GCD of 2233 and 25193 is 59.


To find gcd o two numbers?

You should ask a question here, shouldn't you?