Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started