Question: I'm writing a factorial method in Python 3x and I'm getting this error. Here's my code: def factorial(n): if n == 0: return 1 if
I'm writing a factorial method in Python 3x and I'm getting this error. Here's my code: def factorial(n): if n == 0: return 1 if n > 0: f = n * factorial(n-1) return f

COMPILER STACK TRACE: ERROR: test unitmain .ODINUNITTEST Traceback (most recent call last): File "ODINUNITTEST.py", line 20, in test unit assert factorial (x)ans, f'factorial (x]) is wrong File "q1.py", line 11, in factorial f - n * factorial(n-1) File "q1.py", line 11, in factorial f - n * factorial(n-1) File "q1.py", line 11, in factorial f - n * factorial(n-1) [Previous line repeated 66 more times] File "q1.py", line 4, in factorial RecursionError: maximum recursion depth exceeded in comparison Ran 1 test in 0.001s FAILED (errors-1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
