Factorial_what happended?


#1

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

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


#2

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


#3

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