Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python triangular number

def polygonal(n, sides):
    return (n**2*(sides-2) - n*(sides-4)) // 2

def triangular(n):
    return polygonal(n, 3)
Source by codereview.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #python #triangular #number
ADD COMMENT
Topic
Name
2+3 =