unrated
{title}
{post_time}
You neet to sign in to ask a question. Please sign in.
Request for identifying mistakes in code
Question : Describe your issue or question clearly * more than 20 words.
Why Is My Python Function Not Returning the Expected Result?
I wrote a Python function to calculate the factorial of a number, but it's not returning the correct results. Here's my code.
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n - 1)
print(factorial(5))
I expected it to return 120 for factorial(5), but it's giving me a different number. What am I doing wrong?
word count : 123
Please review your question carefully before submitting. Ensure all details are clear and correct.
Title : Brief, descriptive question title
Loading...
Tags : Enter keywords (e.g., Python, JavaScript)
Loading...
Question :