Listing 08-05: Recursive factorial function

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 08\08.05 - Recursive factorial function.py
# Description: Recursive factorial function
##############################################################################

def factorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n - 1)
Click here to download the file