OFFSET
1,1
COMMENTS
a(n) need not contain a(n-1) as a substring.
We exclude substrings that begin with 0, so a(3) is not 103. - David Wasserman, Aug 12 2005
Agrees with A127891 for 24 terms, but A127891 ends there while this sequence continues. - Ray Chandler, Mar 13 2007
EXAMPLE
a(4) = 1223 in which the four substrings containing the LSD (3,23,223,1223) are primes.
PROG
(PARI) f(n, d, digs, spare) = local(p, r, found); if (!d, return(n)); found = 0; for (i = 0, 9, p = n + i*10^digs; if ((i && isprime(p)) || spare, r = f(p, d - 1, digs + 1, spare - 1 + (i && isprime(p)))); if (r && (r < found || !found), found = r)); found;
a(n) = local(i, r); i = 0; while (1, r = f(0, n + i, 0, i); if (r, return(r), i++)); \\ David Wasserman, Aug 12 2005
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Oct 15 2003
EXTENSIONS
More terms from David Wasserman, Aug 12 2005
STATUS
approved