The Greatest Common Divisor (GCD) for 84 48 is 12
Chat with our AI personalities
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.
GCD stands for the Greatest Common Denominator. No it doesn't. GCD is the greatest common divisor, also known as the greatest common factor. The greatest common Denominator dne.
pictorial representation of a program is called a flowchart
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; }
60=6*10, 126=6*21, so their gcd is 6.I hope ot is not too late for your homework.