The Copeland–Erdős constant is the concatenation of "0." with the base 10 representations of the prime numbers in order. Its value is
See also OEIS A033308.
Copeland and Erdős proved that this is a normal number. This implies that every natural number can be found at some point in the decimal expansion of the Copeland-Erdős constant.
Given a positive integer, express it in base 10 (without leading zeros) and output the index of its first appearance within the sequence of decimal digits of the Copeland–Erdős constant.
Any reasonable input and output format is allowed, but input and output should be in base 10. In particular, the input can be read as a string; and in that case it can be assumed not to contain leading zeros.
Output may be 0-based or 1-based, starting from the first decimal of the constant.
The actual results may be limited by data type, memory or computing power, and thus the program may fail for some test cases. But:
- It should work in theory (i.e. not taking those limitations into account) for any input.
- It should work in practice for at least the first four cases, and for each of them the result should be produced in less than a minute.
Output is here given as 1-based.
13 --> 7 # Any prime is of course easy to find 997 --> 44 # ... and seems to always appear at a position less than itself 999 --> 1013 # Of course some numbers do appear later than themselves 314 --> 219 # Approximations to pi are also present 31416 --> 67858 # ... although one may have to go deep to find them 33308 --> 16304 # Number of the referred OEIS sequence: check 36398 --> 39386 # My PPCG ID. Hey, the result is a permutation of the input! 1234567 --> 11047265 # This one may take a while to find