Compute nth digit of Pi using an asymptotic formula from Plouffe (2022).
Implemented in the following programming languages:
- Python (Python 3.11+)
For
where
Then the nth digit of
The Bernoulli number can be obtained using the Zeta function as follows:
Make sure to have mpmath
installed.
pip install mpmath
from pi_python import pi_nth_digit
pi_nth_digit(10) # 5
To run tests:
pip install pytest
test_pi_python.py -s
This asymptotic formula for calculating the nth digit of pi was discovered by Simon Plouffe in 2022. The paper also discusses a way to calculate the nth digit of pi using Euler numbers.
Big thanks to Martin Bauer for the inspiration and his illustration of this formula.