pls kindly help, I'm stuck in this code

```
def factorial(x):
if x < 2:
return 1
total = 0
count = x
n = 0
while x != 0 and x !=1:
n += 1
count-=1
total = x * x-n
if count == 1:
return total
else:
n += 1
total = total * x-n
count -= 1
if count == 1:
return total
```