According to The Pi-Search Page, in the first 100 million digits of $\pi$ the following numbers are self-locating: 1, 16470, 44899, 79873884.
The following inefficient code (which also does not handle the case of leading 0 digit) finds 16470 and 44899:
Module[{n, k = 5}, n = 10^k - 1;
Position[Apply[Equal, Transpose[{Range[n], FromDigits /@
Partition[Rest@First@RealDigits[Pi, 10, n + k], k, 1]}], 1],True]]
What is an efficient way to find other "fixed points"—and is there an elegant way to use FixedPoint
to find self-locating digit sequences?
Module[{n, m, k = 5}, n = 10^k - 1; m = 10^(k - 1); Pick[Range[m, n], Total /@ Unitize[ Subtract[ IntegerDigits /@ Range[m, n], (Partition[First@RealDigits[Pi - 3, 10, n + k - 1], k, 1])[[m ;; n]]]], 0]]
is much faster. $\endgroup$