Practice ยท 4 of 5
Euclid's algorithm
CHALLENGE
Difficulty: intermediate+25 XP
Implement gcd(int a, int b) recursively: base b == 0 returns a; otherwise gcd(b, a % b). Assumes non-negative inputs.
Examples: gcd(48, 18) โ 6; gcd(7, 13) โ 1.
Press Submit to check your solution.
Back to lesson: Practice: Recursion gauntlet