Digit-Extraction Algorithm

An algorithm which allows digits of a given number to be calculated without requiring the computation of earlier digits. The BBP formula for pi is the best-known such algorithm, but an algorithm also exists for e.

Plouffe (2022) gives a particularly simple digit-extraction algorithm for the decimal digits of pi by defining


Then the nth digit to the right of the decimal point of pi for n>=3 is given by


where int(x) is the integer part and frac(x) is the fractional part. Similar formulas can be obtained using




where E_n is an Euler number, which gives a base-9 (or binary) digit extraction formula (Plouffe 2022). Similar results can be also obtained for pi^2, pi^n, pi^(2n+1), e^pi, lnpi, and sqrt(pi) (Plouffe 2022).

See also

BBP Formula, Pi Digits, Pi Formulas

Explore with Wolfram|Alpha


Plouffe, S. "A Formula for the n'th Decimal Digit or Binary of pi and pi^n." 29 Jan 2022.

Referenced on Wolfram|Alpha

Digit-Extraction Algorithm

Cite this as:

Weisstein, Eric W. "Digit-Extraction Algorithm." From MathWorld--A Wolfram Web Resource.

Subject classifications