def factorial(n):
"""
This function calculates the factorial of a non-negative integer.
Args:
n: The non-negative integer for which to calculate the factorial.
Returns:
The factorial of n, or 1 if n is 0.
Raises ValueError if n is negative.
"""
if n < 0:
raise ValueError("Factorial is not defined for negative numbers")
elif n == 0:
return 1
else:
result = 1
for i in range(1, n + 1):
result *= i
return result
# Example usage:
number = 5
fact = factorial(number)
print(f"The factorial of {number} is {fact}")