# check a sequence in Pi

I read that the string 36541622473 occurs in π(pi) at position 36541622473, counting from the first digit after the decimal point. So I want to check that with the code below. It runs but doesn't return anything. What is wrong with it?

pi = Characters[ToString@N[Pi, 36541622473 + 20]];
pos = SequencePosition[pi, First[RealDigits[36541622473]]]


Update: This is another code that I used but faced the same problem.

pi = N[Pi, 36541622473 + 20];
piList = First[RealDigits[pi]];
SequencePosition[piList, First[RealDigits[36541622473]]]

• Does RealDigits return strings? Isn’t your pi a list of character strings? Why not use RealDigits on Pi? Apr 24, 2021 at 16:32
• @MichaelE2 I added an update the orignal code. Apr 24, 2021 at 16:35
• Why on earth would you expect a general use mathematical software system to return this in a time any less than hours of computation? Easier just to download a dataset with the required range of digits and search that directly.
– ciao
Apr 24, 2021 at 17:23
• @anhnha - I'd venture that "...it finniish..." is more like "...it quits the kernel..." due to memory exhaustion. This can look like it "...doesn't return anything."
– ciao
Apr 24, 2021 at 20:44
• it is interesting to ask how one could use Mathematica to generate the digits of $\pi$ this far without exhausting memory, though (even if it took a long time), which is essentially what this question is doing! Apr 25, 2021 at 0:16

checkPi[n_] :=
ToExpression[Import[StringJoin["https://api.pi.delivery/v1/pi?start=",
ToString@n, "&numberOfDigits=", ToString@IntegerLength@n]][[1,
2]]] == n;

checkPi@36541622473


True

checkPi /@ {1, 16470, 44899, 79873884, 711939213, 36541622473,
45677255610, 62644957128, 656430109694}


{True, True, True, True, True, True, True, True, True}

• What to do if I'm looking for a sequence that starts with zero? Apr 25, 2021 at 12:35
• @Roman - by convention, these are not written in that form (you'd not answer the question "how far?" with "000005 km", yes?).
– ciao
Apr 25, 2021 at 18:04
• @ciao But I might want to search for the first occurrence of the sequence of digits 000005 Apr 26, 2021 at 1:16
• @rohitNamjoshi : that may well be so, but clearly that kind of search is not what the question is about. In any case, the same code can trivially be changed to do naive search.
– ciao
Apr 26, 2021 at 4:13