A240959 Smallest number that contains the first n primes as substrings. Substrings can go from left to right or right to left.
2, 23, 235, 2357, 112357, 113257, 231175, 11325719, 11325719, 11329175, 11329175, 113291735, 3117329145, 11329143715, 411329173475, 3114329173547, 31143291735947, 1132914347167359, 1132914347167359, 1132914347167359, 1132914347167359, 11329143471673597
Offset: 1
Examples
a(7) = 231175, because 231175 is the smallest number that contains the first 7 primes as substrings: 2, 3, 5, 7, 11 and 13. Note that number 13 is contained from right to left.
Links
- Dmitry Kamenetsky, Table of n, a(n) for n = 1..32
- Dmitry Kamenetsky, Results for larger n.
Crossrefs
Cf. A054261.
Programs
-
PARI
allss(d, ss, nbc) = {for (i=1, nbc, for (j=1, #d -i +1, subd = []; subd = concat(subd, d[j]); for (k=1, i-1, subd = concat(subd, d[j+k]);); ss = vecsort(concat(ss, subst(Pol(subd), x, 10)),,8););); return (ss);} isoks(k, n, vp) = {nbc = #Str(prime(n)); d = digits(k); sd = vecsort(d,, 8); for (j=1, #vp, if (!vecsearch(sd, vp[j]), return(0));); ss = []; if (#d < nbc, return(0)); ss = allss(d, ss, nbc); rd = vector(#d, i, d[#d - i +1]); ss = allss(rd, ss, nbc); for (i=1, n, if (! vecsearch (ss, prime(i)), return (0));); return (1);} a(n) = {vp = []; for (i=1, n, dp = digits(prime(i)); for (k=1, #dp, vp = vecsort(concat(vp, dp[k]), ,8););); k = subst(Pol(vp), x, 10); while (!isoks(k, n, vp), k++); k;} \\ Michel Marcus, Aug 28 2014
Formula
a(n) = A054261(n) for n=1 to 6.
Extensions
The author says he is not 100% certain that the later terms are correct, and would appreciate an independent verification. - N. J. A. Sloane, Sep 04 2014
Comments