Solution Review: Find the Greatest Common Divisor
This review provides a detailed analysis of the solution to find the greatest common divisor.
We'll cover the following...
Solution: Using Recursion
Press + to interact
def gcd(testVariable1, testVariable2) :# Base Caseif testVariable1 == testVariable2 :return testVariable1# Recursive Caseif testVariable1 > testVariable2 :return gcd(testVariable1 - testVariable2, testVariable2)else :return gcd(testVariable1, testVariable2 - testVariable1)# Driver Codenumber1 = 6number2 = 9print(gcd(number1, number2))
Explanation
The brute force approach to finding ...
Access this course and 1400+ top-rated courses and projects.