a triangular number or triangle number counts objects arranged in an equilateral triangle this module provides a function to generate n th triangular number for more information about triangular numbers refer to https en wikipedia orgwikitriangularnumber generate the triangular number at the specified position args position int the position of the triangular number to generate returns int the triangular number at the specified position raises valueerror if position is negative examples triangularnumber1 1 triangularnumber3 6 triangularnumber1 traceback most recent call last valueerror param position must be nonnegative generate the triangular number at the specified position args position int the position of the triangular number to generate returns int the triangular number at the specified position raises valueerror if position is negative examples triangular_number 1 1 triangular_number 3 6 triangular_number 1 traceback most recent call last valueerror param position must be non negative
def triangular_number(position: int) -> int:
    
    if position < 0:
        raise ValueError("param `position` must be non-negative")

    return position * (position + 1) // 2


if __name__ == "__main__":
    import doctest

    doctest.testmod()