Listing 08-04: Another way to calculate the factorial

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 08\08.04 - Another way to calculate the factorial.py
# Description: Another way to calculate the factorial
##############################################################################

def factorial(n):
    fat = 1
    x = 1
    while x <= n:
        fat *= x
        x += 1
    return fat
Click here to download the file