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