Factorial 5/15


#1
def factorial (x):
    answer = 1
    for i in range(1, x):
      answer *= i
    return answer
print factorial(5)

what is the issue?


#2

The function range creates a sequence of integers where the first parameter is the starting point and the second parameter is the ending point, but without including it. Therefore, you must change your range values into range(1, x+1) to obtain the apropiate result.

You can check it here.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.