id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav1780@gmail.com 07_recursion > greatest_common_divisor_basic
prev  |  next  |  chance

Greatest common divisor, or GCD, of two numbers is the highest number by which both numbers are divisible. Using the following mathematical fact, gcd(a, b) = gcd(b, a%b) gcd(a, 0) = a Define a recursive function that when passed two integers, returns their their greatest common divisor.


greatest_common_divisor_basic(20, 100) → 20
greatest_common_divisor_basic(72, 48) → 24
greatest_common_divisor_basic(100, 121) → 1

...Save, Compile, Run (ctrl-enter)

def greatest_common_divisor_basic(a, b):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 2 Post-solution available

Copyright Nick Parlante 2017 - privacy