Skip to content

Instantly share code, notes, and snippets.

@babjo
Created July 23, 2016 06:53
Show Gist options
  • Save babjo/f51278e6adb94288d74fb04839335e6d to your computer and use it in GitHub Desktop.
Save babjo/f51278e6adb94288d74fb04839335e6d to your computer and use it in GitHub Desktop.
# Define a procedure, factorial, that takes a natural number as its input, and
# returns the number of ways to arrange the input number of items.

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


print factorial(0)
#>>> 1

print factorial(5)
#>>> 120

print factorial(10)
#>>> 3628800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment