Challenge: Greatest Common Divisor
Find the greatest common divisor (GCD) of two integers using recursion.
We'll cover the following
Problem
Try to find the greatest common divisor of two integers using recursion.
Input
Two integers.
Output
A greatest common divisor (integer).
Sample input
GCD(24, 18)
Sample output
GCD is: 6
Coding exercise
Try to solve this yourself first. If you get stuck or need help, you can always press the āShow Solutionā button to see how your problem can be solved. Weāll look at the solution in the next lesson.
Good luck!
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.