Quick, hackers: what the algorithm for the maximum amount of money he could earn in 365 days?
>>> (sum(xrange(1,366)))
66795The constant time approximation is (count^2) / 2
365 * 365 / 2 = 66,612.5
I'm sure there is a constant time exact solution as well :-)
x = 365; ((x + 1) * x) / 2 # 66795
For x > 2 and odd.