Given two positive integers a and b, return their greatest common divisor (GCD) and least common multiple (LCM) as a two-element array [gcd, lcm].
The GCD is the largest positive integer that divides both a and b. The LCM is the smallest positive integer that is divisible by both a and b.
For example, gcdLcm(12, 8) returns [4, 24] because the GCD of 12 and 8 is 4, and their LCM is 24.
a = 12, b = 8[4, 24]a = 7, b = 3[1, 21]a = 6, b = 6[6, 6]1 <= a, b <= 10^9Both a and b are positive integers.Run your code to see results
Use Cmd+Enter to run