To fix your factorial function, you need to update the loop condition and the way variables are updated. Here's a concise version of the corrected code:
def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
In this modified code, the loop iterates over the range from 1 to n+1, multiplying result by each value of i. Finally, the updated result is returned as the factorial value.