2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-05 12:00:16 +00:00
cheat.sheets/sheets/_python/recursion
2017-07-19 05:29:43 +00:00

16 lines
332 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)