cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A240959 Smallest number that contains the first n primes as substrings. Substrings can go from left to right or right to left.

Original entry on oeis.org

2, 23, 235, 2357, 112357, 113257, 231175, 11325719, 11325719, 11329175, 11329175, 113291735, 3117329145, 11329143715, 411329173475, 3114329173547, 31143291735947, 1132914347167359, 1132914347167359, 1132914347167359, 1132914347167359, 11329143471673597
Offset: 1

Views

Author

Dmitry Kamenetsky, Aug 04 2014

Keywords

Comments

In this version substrings can go from left to right or right to left. The version that only allows substrings to go from left to right is A054261.

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.
		

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