Recursive Functions in Python

I spent the weekend learning more about Python on Udacity.com. I went through Unit 6 which was all about recursive procedures in Python.

A recursive function is basically a function that calls itself.  An example of this would be:

def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n - 1)

Recursion is great because it allows you to write code that is much simpler and cleaner than if you had to write the same code using if/while procedures.

Published by

Joel Gross

Joel Gross is the CEO of Coalition Technologies.