Medium
Identify Logic Error in Python
Find and explain the logic error in a specific code snippet.
📝 Conteúdo do Prompt
Analyze the following Python function that is supposed to return the factorial of a number but is currently entering an infinite loop for inputs greater than 1. Explain why the recursion fails and provide the corrected code snippet:
def factorial(n):
result = 1
while n > 1:
result = result * n
return result