advanced
Debug Python Code Logic
Identify and fix a logical error in a code snippet.
📝 प्रॉम्ट सामग्री
Analyze the following Python code snippet designed to calculate the factorial of a number. Identify why it returns zero for the input 5 and provide the corrected code: def factorial(n): result = 0; for i in range(1, n+1): result *= i; return result