Write a function to calculate the factorial of a given number, and explain the edge cases such as the factorial of zero.
Implement factorial(n), where n is a non-negative integer. Return the exact integer value of n!, with 0! defined as 1.
def factorial(n):