Find numbers within the Copeland–Erdős constant
Python 2, 64 bytes
f=lambda n,k=2,m=1,s='':-~s.find(`n`)or f(n,k+1,m*k*k,s+m%k*`k`)
Returns the 1-based index. Test it on Ideone.
05AB1E, 14 bytes
Uses 0-indexed output. Prime functions in osabie are very inefficient. Code:
[NØJD¹å#]¹.Oð¢
Explanation:
[ ] # Infinite loop...
N # Get the iteration value
Ø # Get the nth prime
J # Join the stack
D # Duplicate this value
¹å# # If the input is in this string, break out of the loop
¹.O # Overlap function (due to a bug, I couldn't use the index command)
ð¢ # Count spaces and implicitly print
Uses the CP-1252 encoding. Try it online!.
Jelly, 17 bytes
ÆRDFṡL}i
Ḥçßç?
çD
Returns the 1-based index. Try it online! or verify most test cases.
I've verified the last test case locally; it took 8 minutes and 48 seconds.
How it works
çD Main link. Argument: n (integer)
D Decimal; yield A, the array of base 10 digits of n.
ç Call the second helper link with arguments n and A.
Ḥçßç? Second helper link. Left argument: n. Right argument: A.
Ḥ Unhalve; yield 2n.
? If...
ç the first helper link called with 2n and A returns a non-zero integer:
ç Return that integer.
Else:
ß Recursively call the second helper link with arguments 2n and A.
ÆRDFṡL}i First helper link. Left argument: k. Right argument: A.
ÆR Prime range; yield the array of all primes up to k.
DF Convert each prime to base 10 and flatten the resulting nested array.
L} Yield l, the length of A.
ṡ Split the flattened array into overlapping slices of length l.
i Find the 1-based index of A in the result (0 if not found).
Alternate version, 11 bytes (non-competing)
ÆRVw³
ḤÇßÇ?
The w
atom did not exist when this challenge was posted. Try it online!
How it works
ḤÇßÇ? Main link. Argument: n (integer)
Ḥ Unhalve; yield 2n.
? If...
Ç the helper link called with argument 2n returns a non-zero integer:
Ç Return that integer.
Else:
ß Recursively call the main link with argument 2n.
ÆRVw³ Helper link. Argument: k (integer)
ÆR Prime range; yield the array of all primes up to k.
V Eval; concatenate all primes, forming a single integer.
³ Yield the first command-line argument (original value of n).
w Windowed index of; find the 1-based index of the digits of the result to
the right in the digits of the result to the left (0 if not found).