The code is responding with "factorial(2) returned 1 instead of 2." Trying to figure out what I did incorrectly.

```
def factorial(x):
total=1
for i in range(x):
if x<=1:
return x
else:
while i>=x:
total=total*i
return total
```