# Finding a specific number in Pi

**URL:** <https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972>\
**Category:** Factual Questions\
**Created:** [January 6, 2018, 7:00am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972 "2018-01-06T07:00:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Jackson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lucas_jackson/32/303_2.png) [@Lucas\_Jackson](https://boards.straightdope.com/u/Lucas_Jackson)\
**Post date:** [January 6, 2018, 7:00am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/1 "2018-01-06T07:00:16Z")

</div>

If I wanted to find the 3,257,001st (for example) number in Pi, how would I do it? Is there a website or a sequence generator?

Thanks.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 6, 2018, 7:15am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/2 "2018-01-06T07:15:45Z")

</div>

[Here you go](http://www.angio.net/pi/digits.html).

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [January 6, 2018, 7:31am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/3 "2018-01-06T07:31:11Z")

</div>

It’s a 3!

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [January 6, 2018, 12:58pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/4 "2018-01-06T12:58:43Z")

</div>

If you want it in base 10, the only (known) way to get it is by generating all of the digits out to that point (or by finding someone else who has done so). Amazingly, though, if you want it in base 16 (or base 2 or any other base that’s a power of 2), there’s actually a formula that will find digits individually.

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [January 6, 2018, 1:35pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/5 "2018-01-06T13:35:54Z")

</div>

Simon Plouffe [seems to claim otherwise](http://www.lacim.uqam.ca/~plouffe/Simon/articlepi.html).

---

<div class="post-metadata">

**Author:** ![Lucas\_Jackson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lucas_jackson/32/303_2.png) [@Lucas\_Jackson](https://boards.straightdope.com/u/Lucas_Jackson)\
**Post date:** [January 6, 2018, 2:18pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/6 "2018-01-06T14:18:38Z")

</div>

> [@friedo](#):
>
> It’s a 3!

Thanks but how did you find it?

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [January 6, 2018, 5:11pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/7 "2018-01-06T17:11:06Z")

</div>

How many digits do you need? There are both websites with hundreds of billions of digits (or more) that you can download ([here](http://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt) is a billion to get you started) and programs to generate them yourself (eg try Super Pi).

---

<div class="post-metadata">

**Author:** ![Leo\_Bloom](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/leo_bloom/32/10377_2.png) [@Leo\_Bloom](https://boards.straightdope.com/u/Leo_Bloom)\
**Post date:** [January 6, 2018, 10:25pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/8 "2018-01-06T22:25:06Z")

</div>

[Plouffe](https://en.wikipedia.org/wiki/Simon_Plouffe), for shits and giggles also co-founded the [On-Line Encyclopedia of Integer Sequences](http://oeis.org), one of the most extraordinary things on God’s green Earth.

You got numbers? They got numbers.

---

<div class="post-metadata">

**Author:** ![Leo\_Bloom](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/leo_bloom/32/10377_2.png) [@Leo\_Bloom](https://boards.straightdope.com/u/Leo_Bloom)\
**Post date:** [January 6, 2018, 10:34pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/9 "2018-01-06T22:34:55Z")

</div>

> [@Leo\_Bloom](#):
>
> [Plouffe](https://en.wikipedia.org/wiki/Simon_Plouffe), for shits and giggles also co-founded the [On-Line Encyclopedia of Integer Sequences](http://oeis.org), one of the most extraordinary things on God’s green Earth.
> 
> You got numbers? They got numbers.

Cx: “Co-founded” is wrong. [OEIS](https://en.wikipedia.org/wiki/On-Line_Encyclopedia_of_Integer_Sequences) started out, and was and is shepherded by [Neil Sloane](https://en.wikipedia.org/wiki/Neil_Sloane).

---

<div class="post-metadata">

**Author:** ![Lucas\_Jackson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lucas_jackson/32/303_2.png) [@Lucas\_Jackson](https://boards.straightdope.com/u/Lucas_Jackson)\
**Post date:** [January 7, 2018, 12:39am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/10 "2018-01-07T00:39:56Z")

</div>

> [@DPRK](#):
>
> How many digits do you need? There are both websites with hundreds of billions of digits (or more) that you can download ([here](http://stuff.mit.edu/afs/sipb/contrib/pi/pi-billion.txt) is a billion to get you started) and programs to generate them yourself (eg try Super Pi).

Maybe my OP wasn’t clear. Here is Pi:

3.14159265…

If i wanted to know what the 2nd number in Pi was (past the decimal) I could just count. It’s 4. If I wanted to know what the 7th number was I could just count - it’s 6. But what if I wanted to know what the 34,346th number was? I could go to your link and count but that would take while. Or maybe I was looking for the 670,934th number?

Given that there is a list of a billion digits, I was hoping that there was a program that could search through them and tell me what the numeral was at a specific number count past the decimal.

This site looks like it has promise:

> **[The Pi-Search Page](https://angio.net/pi/)**
>
> Search for any string of digits in the first 200 million digits of Pi

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [January 7, 2018, 4:16am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/11 "2018-01-07T04:16:22Z")

</div>

You might expect that you’d need to go out a million digits or so before encountering six consecutive 9’s. But (disturbingly!) there is a such a run after only 762 digits. Douglas Hofstadter wanted to memorize pi far enough to be able to say

```auto

Pi is 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999 and so on

```

… and get listener running for the .99999… = 1? thread … but he was only able to memorize about half-way.

---

<div class="post-metadata">

**Author:** ![sweepkick](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@sweepkick](https://boards.straightdope.com/u/sweepkick)\
**Post date:** [January 7, 2018, 4:43am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/12 "2018-01-07T04:43:11Z")

</div>

> [@Lucas\_Jackson](#):
>
> Maybe my OP wasn’t clear. Here is Pi:
> 
> 3.14159265…
> 
> If i wanted to know what the 2nd number in Pi was (past the decimal) I could just count. It’s 4. If I wanted to know what the 7th number was I could just count - it’s 6. But what if I wanted to know what the 34,346th number was? I could go to your link and count but that would take while. Or maybe I was looking for the 670,934th number?
> 
> Given that there is a list of a billion digits, I was hoping that there was a program that could search through them and tell me what the numeral was at a specific number count past the decimal.
> 
> This site looks like it has promise:  
> [The Pi-Search Page](http://angio.net/pi/)

In the first link provided by Dr. Strangelove, put 34346 in the “starting position” text box, click on the “show pi”, and the first number that pops up in the string of 10 is the 34,346th digit in Pi.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [January 7, 2018, 5:24am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/13 "2018-01-07T05:24:24Z")

</div>

Does pi contain itself?

That is, for any _n_ however large, can I find the first _n_ digits of pi somewhere else farther along in the number?

(Just thinking a bit about this: If so, then it must occur farther than _n_ digits into the number.)

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 7, 2018, 6:11am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/14 "2018-01-07T06:11:34Z")

</div>

> [@Senegoid](#):
>
> That is, for any _n_ however large, can I find the first _n_ digits of pi somewhere else farther along in the number?

No one knows. If pi is a [normal number](https://en.wikipedia.org/wiki/Normal_number), then yes. And most likely, pi is a normal number, but no one has a proof of this.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [January 7, 2018, 6:17am UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/15 "2018-01-07T06:17:35Z")

</div>

> [@Senegoid](#):
>
> (Just thinking a bit about this: If so, then it must occur farther than _n_ digits into the number.)

Thinking about it a bit more: Forget the above.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [January 7, 2018, 6:45pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/16 "2018-01-07T18:45:24Z")

</div>

> [@septimus](#):
>
> Simon Plouffe [seems to claim otherwise](http://www.lacim.uqam.ca/~plouffe/Simon/articlepi.html).

A couple of questions about this:

1. The formula given at the top is the hypergeometric identity [sub]2[/sub]F[sub]1/sub = π + 3. What is the clearest (in your opinion) way to see this?

2. The method outlined claims to compute the n’th digit in time C_n^3_log(n)^3. Practically speaking, how does that compare to the methods currently used to compute many trillions of digits via summing terms of Chudnovsky-type series? I do understand that Plouffe’s goal is to save storage space, not necessarily time (on the other hand, continuously reading and writing 100s of terabytes to hard disks takes time).

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [January 7, 2018, 7:06pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/17 "2018-01-07T19:06:53Z")

</div>

> [@Lucas\_Jackson](#):
>
> If I wanted to find the 3,257,001st (for example) number in Pi, how would I do it?

First, a nitpick: by “number” I think you mean “digit.” Pi itself is a number.

If you’re willing to settle for finding a specific digit in the _binary_ (base two) or hexadecimal (base 16) expansion of Pi, you could use the [Bailey–Borwein–Plouffe formula](https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula) formula, alluded to upthread. I don’t think—someone correct me if I’m wrong—that there’s any currently known way of finding a specific digit in the _decimal_ expansion of pi without finding all the digits up to that point.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [January 7, 2018, 7:41pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/18 "2018-01-07T19:41:09Z")

</div>

It’s all been pre-calculated, though. Post #12 answers the question in the OP (to the limits of the current version of that web site, currently 200 million digits or something like that).

ETA by “all… pre-calculated” I mean low-order digits like the 3257001st one the OP wanted, not multi-quadrillions and beyond.

---

<div class="post-metadata">

**Author:** ![GreysonCarlisle](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@GreysonCarlisle](https://boards.straightdope.com/u/GreysonCarlisle)\
**Post date:** [January 7, 2018, 8:19pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/19 "2018-01-07T20:19:45Z")

</div>

Is there some particular application you want this for? If you’re using it for cryptography or randomness, you could treat the value of pi as text instead of as numeric. Make a text file with pi written out as far as you need it to go, then use a Mid(_x_, 1)-like function (you may need to break the string into chunks) or just go through the text file to the _x_th character (or _x_ + 2 if you’re keeping the initial “3.” in the file). Then convert the return value from a string to an integer.

I just made a text file of pi to the 10-millionth digit, and the file is only about 9900 kb.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 7, 2018, 8:22pm UTC](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972/20 "2018-01-07T20:22:27Z")

</div>

> [@DPRK](#):
>
> 1. The method outlined claims to compute the n’th digit in time C_n^3_log(n)^3. Practically speaking, how does that compare to the methods currently used to compute many trillions of digits via summing terms of Chudnovsky-type series?

I don’t know much about the Chudnovsky algorithm or why it’s used. However, I have implemented the Borwein quadratic algorithm. It doubles the number of digits on each step, so there’s a log(n) term. Each step requires some square roots and divides, which themselves have quadratic convergence algorithms, so there’s another log(n) factor. Finally, the root/divide steps require multiplies, which can be done in n\*log(n) time using a fast fourier transform or other fast convolution method.

That multiplies out to O(n\*log(n)[sup]3[/sup]), which is a difference of n[sup]2[/sup]. So yeah, this is really only of theoretic concern.

[Next page](https://boards.straightdope.com/t/finding-a-specific-number-in-pi/805972.md?page=2)
