Listing 08-06: Modified function to facilitate tracing

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

def factorial(n):
    print(f"Calculating the factorial of {n}")
    if n == 0 or n == 1:
        print(f"Factorial of {n} = 1")
        return 1
    else:
        fat = n * factorial(n - 1)
        print(f" factorial of {n} = {fat}")
    return fat
factorial(4)
Click here to download the file