Post

Day 40 of 100 Days of Python

Practising Recursion

1
2
3
4
5
6
7
8
9
# Greatest common diviser with recursion

def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)
a = 48
b = 18
print(gcd(a,b))
This post is licensed under CC BY 4.0 by the author.

Trending Tags