hexagonal number the nth hexagonal number hn is the number of distinct dots in a pattern of dots consisting of the outlines of regular hexagons with sides up to n dots when the hexagons are overlaid so that they share one vertex https en wikipedia orgwikihexagonalnumber akshay dubey https github comitsakshaydubey param number nth hexagonal number to calculate return the nth hexagonal number note a hexagonal number is only defined for positive integers hexagonal4 28 hexagonal11 231 hexagonal22 946 hexagonal0 traceback most recent call last valueerror input must be a positive integer hexagonal1 traceback most recent call last valueerror input must be a positive integer hexagonal11 0 traceback most recent call last typeerror input value of number11 0 must be an integer akshay dubey https github com itsakshaydubey param number nth hexagonal number to calculate return the nth hexagonal number note a hexagonal number is only defined for positive integers hexagonal 4 28 hexagonal 11 231 hexagonal 22 946 hexagonal 0 traceback most recent call last valueerror input must be a positive integer hexagonal 1 traceback most recent call last valueerror input must be a positive integer hexagonal 11 0 traceback most recent call last typeerror input value of number 11 0 must be an integer
def hexagonal(number: int) -> int:
    
    if not isinstance(number, int):
        msg = f"Input value of [number={number}] must be an integer"
        raise TypeError(msg)
    if number < 1:
        raise ValueError("Input must be a positive integer")
    return number * (2 * number - 1)


if __name__ == "__main__":
    import doctest

    doctest.testmod()