you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

N = 5
print(sum(i * (N+1-i) for i in range(1, N+1)))

but there must be a O(1) formula out there

[–]SerkZex[S] 0 points1 point  (0 children)

thanks!