GCD and LCM
Write code · Medium · §2.2 Divisors and multiples
You are given two positive integers a and b. Complete the function solution, which returns a list of their greatest common divisor (GCD) and least common multiple (LCM), in that order: [GCD, LCM].
Function
solution(a, b)
Constraints
aandbare integers from 1 to 10,000,000,000.
Examples
| a | b | result |
|---|---|---|
12 | 18 | [6, 36] |
4 | 6 | [2, 12] |
Starter code
def solution(a, b):
answer = [0, 0]
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.