Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python triangular number

def triangular_number(n):
    for i in range(n):  # range(3) is a generator for [0, 1, 2]
        n += i
    return n
Source by codereview.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #python #triangular #number
ADD COMMENT
Topic
Name
9+6 =