← Back to challenges

Recursion: GCD

PythonHardrecursionmath

Instructions

Write a function that calculates the GCD (Greatest Common Divisor) of two numbers recursively.

Examples

gcd(10, 20) ➞ 10

gcd(1, 3) ➞ 1

gcd(5, 7) ➞ 1

gcd(2, 6) ➞ 2

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Format IV: Escaping Curly Braces