"""
Recommended Python Style Guide:
https://peps.python.org/pep-0008/#introduction
"""


def factorial(n):
    """
    Recursively calculates the factorial of a non-negative integer n.

    Parameters:
    n (int): The integer for which to calculate the factorial. Must be non-negative.

    Returns:
    int: The factorial of n.
    """
    # Base case: factorial of 0 or 1 is 1
    if n <= 1:
        return 1
    else:
        # Recursive case: n * factorial of (n-1)
        return n * factorial(n - 1)


# Prompt user to enter a non-negative integer
n = int(input("Enter a non-negative integer for n: "))
# Validate input to ensure n is non-negative
while n < 0:
    print("Please enter a non-negative value for n.")
    n = int(input("Enter a non-negative integer for n: "))

# Output the factorial result
print(f"factorial({n}) = {factorial(n)}")
