Factorial_what happended?


This is the error :factorial(2) resulted in an error: ‘int’ object is not callable
this is link below

def factorial(x):
if x == 0:
return 1
elif x == 1:
return 1
i = 1
while i < x:
y = x(x-i)
return y


Not quite understanding your code yet, but your problem is here: y = x(x-i). This just doesn’t work. For example: if your input for x is 2 this will translate to y = 2(2-1). That doesn’t mean anything to python.
Also I don’t see any multiplication in your code. I would suggest to read the assignment instructions again and rewrite your code


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