Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ This is a factorial function with an argument that returns the
- factorial of a supplied integer argument"""
- # The function has a base statement which the function returns to
- # to avoid looping
- def factorial(value):
- if value == 1: # The base statement
- return value
- else:
- return value * factorial(value - 1) # The function calling itself
- # Function Invokation
- print(factorial(1))
- print(factorial(2))
- print(factorial(3))
- print(factorial(4))
- print(factorial(5))
Advertisement
Add Comment
Please, Sign In to add comment