2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-15 06:12:59 +00:00
cheat.sheets/sheets/_python/recursion
2020-10-15 18:29:27 +01:00

16 lines
320 B
Plaintext

# For what Recursion is, please check theory/recursion
# Simple Factorial Python Recursion
def factorial(n) :
if n == 0 :
return 1
else :
return n * factorial(n-1)
# Simple Greatest Common Divisor Recursion
def gcd(x, y) :
if y == 0 :
return x
else :
return gcd(y, x%y)