def factorial(n):
    """
    Returns the factorial of n

    Parameters
    ----------
    n : int
        denotes the non-negative integer for which factorial value is needed
    
    """
    if(n<0):
        raise NotImplementedError(
            "Enter a valid non-negative integer"
        )
    
    if(n==0 or n==1):
        return 1
    elif(n==2):
        return 2
    return n*factorial(n-1)