greatest common divisor
Euclidean algorithm (rolling and dividing method) :
- Greatest Common Divisor (Greatest Common Divisor) abbreviated as GCD
- g c d ( a , b ) = g c d ( b , a m o d b ) gcd(a,\ b) = gcd(b,\ a\ mod\ b) gcd(a, b)=gcd(b, a mod b)
private static int gcd(int a, int b) {
return (b == 0 ? a : gcd(b, a % b));
}
gcd ( a , b ) = gcd ( a , b − a ) . where a ≤ b gcd(a,\ b)=gcd(a,\ ba).\ where a\ ≤\ bgcd(a, b)=gcd(a, b−a ) . _ _ ≤ b
least common multiple
- Least common multiple of two numbers * Greatest common divisor = product