Loading...
Loading...
Loading...
Two delivery vans visit a depot every a and b days. Write a function gcd_lcm(a, b) that returns the greatest common divisor and the least common multiple as two values, using the Euclidean algorithm. Print them on one line.
Example
Input
12 18
Output
6 36
GCD 6, LCM 36.
Try the problem first. Open one hint at a time.
Repeat a, b = b, a % b while b is not 0. The value left in a is the GCD.
The LCM is a * b // gcd, using the original values.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor