0

Why on line 5 do we need to use the factorial function?Python

def factorial(x): if x == 1: return 1 else: return x * factorial(x-1) print(factorial(5))

5th Jun 2020, 1:18 PM
3.14
3.14 - avatar
1 Odpowiedź
+ 2
For this particular function to work properly, it needs to call itself until x is 1, like Kiibo Ghayal said.
5th Jun 2020, 1:44 PM
CeePlusPlus
CeePlusPlus - avatar