Today, Numberphile posted this video where it's stated that 1+2+3+4+...+n = -1/12.

While this isn't really new (several ways to prove that have been found, you can look here for further informations), this leads us to our question!

Your goal is to write a function that returns -0.083333 (feel free to stop at -0.083 if you wish), which is -1/12.

Be original, since this is a !

Most upvoted answer in 2 weeks wins this.

  • \$\begingroup\$ I don't understand, does this mean that infinity is -1/12? \$\endgroup\$
    – user10766
    Commented Jan 9, 2014 at 19:23
  • \$\begingroup\$ No, but there are several mathematic methods to calculate this value as the result of that sum. Read the link I gave for more informations about that, this would be off-topic here I guess! :) \$\endgroup\$
    – Vereos
    Commented Jan 9, 2014 at 19:28
  • \$\begingroup\$ These wikipedia articles seem relevant: en.wikipedia.org/wiki/… en.wikipedia.org/wiki/… \$\endgroup\$
    – Justin
    Commented Jan 9, 2014 at 19:50

3 Answers 3


The Riemann Zeta function is defined as ζ(s) = Sum(n-s) where you sum from n=1 to n=infinity. Hence ζ(-1) = Sum(n) = 1 + 2 + 3 + 4 + ... to infinity.

Now scipy defines zetac to be sum(k**(-x), k=2..inf) (that is the zeta function with the first term removed).

Hence in python

>>> import scipy.special
>>> print 1+scipy.special.zetac(-1)

essentially calculates the infinite sum 1+2+3+4+... to give -1/12.



This is quite short, but I hope you think it's sweet:


I'm relying on the fact that a negative twelfth is -0.1111111... in base thirteen. This function takes its argument, decrements it, and divides by 13 (a right-shift in base 13). It does this until the value converges to -1/12. To see how the base 13 stuff fits in, you might want to imagine the 13 being changed to a 10. The function would then converge at decimal -0.111111... = -1/9.


PowerShell (and probably a polyglot)

I know this isn't code-golf, but since no other parameters are really defined for the challenge except:

Your goal is to write a function that returns -0.083333 (feel free to stop at -0.083 if you wish), which is -1/12.

I have a really hard time justifying doing anything other than:


This outputs:


Not the answer you're looking for? Browse other questions tagged or ask your own question.