Skip to main content
3 of 3
Commonmark migration

Pyth - 15 10 * .5 = 5

smr-QdhQUQ

Try it online.

Expects input on stdin. Independently discovered algorithm. Thanks @Sp3000 for helping me stick the last Q in there :P Also, irony? XD

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 m      UQ            : map(...,range(Q))
  r-QdhQ              : range(Q-d,Q+1)
     
FryAmTheEggman
  • 17.5k
  • 3
  • 40
  • 97