News for hackers. Stuff that matters.
Re:A Million Digits of Pi in 9 Lines of JavaScript by hervature on Thursday September 12, 2019 @02:56PM (#20955037)
What is the actual equation? They just list the first couple of terms.
Re:A Million Digits of Pi in 9 Lines of JavaScript by mkl on Thursday September 12, 2019 @05:53PM (#20956871)
Continuing the pattern it's

  $\pi = 3 + \sum_{k=1}^\infty 3 \frac{(2k-1)!!}{(2k)!!} \frac{1}{2k+1} \frac{1}{4^k}$ [1].
n!! is double factorial, the product of odd or even numbers up to n (depending on whether n is odd or even) [2].

Edit: added a simpler series from https://math.stackexchange.com/a/14116:

  $\pi = \sum_{k=0}^{\infty} \frac{(2k)!!}{(2k+1)!!} \left(\frac{1}{2}\right)^{k-1}$
[1] https://imgur.com/a/YtA8kUx

[2] https://en.wikipedia.org/wiki/Double_factorial

Re:A Million Digits of Pi in 9 Lines of JavaScript by ajennings on Thursday September 12, 2019 @03:03PM (#20955112)
Good question. I just presented it here the way it was given to me, as a couple initial terms and some rules on how it evolves, because I find that to be the easiest way to remember it.

The actual formula looks much less friendly (because it's tricky to write "the product of the first n odd integers"), but it's a good exercise for those who are inclined.

Re:A Million Digits of Pi in 9 Lines of JavaScript by hsnewman on Thursday September 12, 2019 @03:04PM (#20955123)
The article says: let i = 1n; let x = 3n * (10n 1000020n); let pi = x; while (x > 0) { x = x * i / ((i + 1n) * 4n); pi += x / (i + 2n); i += 2n; } console.log(pi / (10n 20n));