<s>[INST] How do you use the BBP Formula to calculate the nth digit of π? I know what the Bailey-Borweim-Plouffe Formula (BBP Formula)  is—it's $\pi = \sum_{k = 0}^{\infty}\left[ \frac{1}{16^k} \left( \frac{4}{8k + 1} - \frac{2}{8k + 4} - \frac{1}{8k + 5} - \frac{1}{8k + 6} \right) \right]$— but how exactly do I use it to calculate a given digit of pi?
 [/INST] The basic idea depends on the following easy result:
The $d+n$-th digit of a real number $\alpha$ is obtained by computing the $n$-th digit of the fractional part of $b^d \alpha$, in base $b$ . (fractional part denoted by $\lbrace \rbrace$.)
For instance:
if you want to find the $13$-th digit of $\pi$ in base $2$, you must calculate the fractional part of $2^{12} \pi$  in base $2$.
$\lbrace2^{12} \pi\rbrace=0.\color{red} 1\color{blue} {111011}..._2$
hence $13$-th digit of $\pi $ is $\color{red} 1$.
$\pi=11.001001000011\color{red} 1\color{blue} {111011010101}..._2$
Now if we want to compute the $n+1$-th hexadecimal digit of $\pi$
we only need to calculate  $\lbrace 16^{n} \pi\rbrace$
you can  do this by using $BBP$ formula
$$\pi = \sum_{k = 0}^{\infty} \frac{1}{16^k} \left( \frac{4}{8k + 1} - \frac{2}{8k + 4} - \frac{1}{8k + 5} - \frac{1}{8k + 6} \right) $$
$$16^{n} \pi= \sum_{k = 0}^{\infty}  \left( \frac{4 \cdot 16^{n-k}}{8k + 1} - \frac{2\cdot 16^{n-k}}{8k + 4} - \frac{ 16^{n-k}}{8k + 5} - \frac{16^{n-k}}{8k + 6} \right)$$
and
$$\lbrace 16^{n} \pi\rbrace=\bigg\lbrace\sum_{k = 0}^{\infty}  \left( \frac{4 \cdot 16^{n-k}}{8k + 1} - \frac{2\cdot 16^{n-k}}{8k + 4} - \frac{ 16^{n-k}}{8k + 5} - \frac{16^{n-k}}{8k + 6} \right)\bigg \rbrace$$
Now let $S_j=\sum_{k=0}^{\infty} \frac{1}{16^k(8k+1)}$ then
$$\color{blue}{\lbrace 16^{n} \pi\rbrace=\lbrace 4\lbrace 16^{n} S_1\rbrace-2\lbrace 16^{n} S_4\rbrace-\lbrace 16^{n} S_5\rbrace-\lbrace 16^{n} S_6\rbrace \rbrace}$$
using the $S_j$ notation
$$\lbrace 16^{n} S_j\rbrace=\bigg \lbrace \bigg \lbrace\sum_{k=0}^{n}\frac{16^{n-k}}{8k+j} \bigg \rbrace+\sum_{k=n+1}^{\infty}\frac{16^{n-k}}{8k+j}\bigg \rbrace $$
$$=\bigg \lbrace \bigg \lbrace\sum_{k=0}^{n}\frac{16^{n-k} \mod {8k+j} }{8k+j} \bigg \rbrace+\sum_{k=n+1}^{\infty}\frac{16^{n-k}}{8k+j}\bigg \rbrace$$
Now compute $\lbrace 16^{n} S_j\rbrace$ for $j=1,4,5,6$, combine these four result, then discarding integer parts.
The resulting fraction, when expressed in hexadecimal notation, gives the hex digit of $\pi$ in position $n+1$ .
</s>