Example: 30 and 42 Factor them. 2 x 3 x 5 = 30 2 x 3 x 7 = 42 Select the common factors. 2 x 3 = 6, the GCF
42
gcd
public class GCD { public static int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } public static int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); } }
Something that is similar to an actual program. Example: Define gcd (a, b) as a if b==0 b if a==0 gcd (a, b modulo a) if a<=b gcd (b, a modulo b) if a>b
Greatest Common Divisor (GCD) for 30 42 is 6.
If you mean the greatest common divisor (or factor), the answer is 6
The Greatest Common Divisor (GCD) for 30 42 is 6.
GCD(66, 90) = 6
GCD of 81 and 66 is 3.
GCD(42, 65) = 1
The GCD of 14, 42 is 14.
GCD: 21
GCD: 14
GCD: 14
The GCF is 3.
The Greatest Common Divisor (GCD) for 42 56 is 14.