##Pyth - 15 * .5 = 7.5
s+mrhQ-Qdr1Q]]Q
Expects input on stdin. Independently discovered algorithm.
Explanation:
Q=eval(input()) : implicit
s : The sum of...
+ ]]Q : Add [[Q]] to the end of...
m r1Q : map(...,range(1,Q))
rhQ-Qd : range(Q-d,Q+1)[::-1]
Sadly, pyth's sum
function will crash on an empty list, so I lose a byte having to add Q
to the list before summing (otherwise 1
would crash).