D. Bailey, P. Borwein, and S. Plouffe (called "BBP") came up with this
formula for $\pi$:

$\pi=\sum\limits_{n=0}^\infty \frac{1}{16^n}\left(\frac{4}{8n+1}-\frac{2}{8n+4}-\frac{1}{8n+5}-\frac{1}{8n+6}\right)$ (from "Pi Unleashed," by J. Arndt and C. Haenel, p. 117).

Use a for loop of about 10 terms, and see how close this sum comes to $\pi$.

Type your code here:

See your results here:

This code will not run! Fix the for-loop to run over your desired number of terms, and fix the

Here's another formula to try:

`term=`

line
to be the formula for each "term" in the sum (the $\frac{1}{16^n}\left(...\right)$ in the formula
above).
Here's another formula to try:

$\pi=\sum\limits_{n=1}^\infty\frac{1}{n^3}\left(\frac{-238}{n+1}+\frac{285/2}{2n+1}-\frac{667/32}{4n+1}-\frac{5103/16}{4n+3}+\frac{35625/32}{4n+5}\right)$

This one was found by Adamchik and Wagon in 1997 (see p. 227 of "Pi Unleashed).

Does your code work? Want to run it on your iPhone?

Here's your code:

- Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.
- Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
this page
- Then click the "Use on iPhone" button that you'll see.