```
# Using for loop
def factorial(x):
if x < 0:
return "Factorial does not exist for negative integers."
else:
result = 1
for i in range(1, x + 1):
result *= i
return result
```

```
# Using while loop
def factorial(x):
if x < 0:
return "Factorial does not exist for negative integers."
else:
result = 1
while x >= 1:
result *= x
x -= 1
return result
```

```
# If recursion is allowed
def factorial(x):
if x < 0:
return "Factorial does not exist for negative integers."
if x == 0:
return 1
return x * factorial(x - 1)
```

FYI, there is also built-in factorial() in math module.

```
from math import factorial
print(factorial(x)) # Replace x with an integer >= 0
```

Hope that helps.