login
A375015
Lexicographically earliest sequence of distinct positive terms such that either the concatenation [a(n); n; a(n+1)] or the concatenation [a(n+1); n; a(n)] is a prime number.
1
1, 2, 3, 4, 9, 6, 19, 8, 7, 10, 21, 11, 17, 13, 5, 39, 16, 29, 14, 31, 20, 27, 24, 57, 23, 32, 33, 26, 53, 12, 49, 35, 37, 15, 43, 22, 67, 30, 59, 18, 73, 28, 61, 41, 51, 70, 47, 25, 69, 34, 89, 42, 79, 38, 71, 52, 77, 48, 93, 45, 91, 44, 63, 58, 99, 36, 83, 50, 87, 55
OFFSET
1,2
COMMENTS
The sequence is a rearrangement of the positive integers.
LINKS
Eric Angelini, Rightmost digit, leftmost digit, variants, Personal blog of the author.
EXAMPLE
The first 11 terms are 1,2,3,4,9,6,19,8,7,10,21. Successively inserting n between a(n) and a(n+1) produce:
112, 223, 334, 449, 956, 6619, 1978, 887, 7910, 101021.
If such a concatenation is composite, the concatenation [a(n+1);n;a(n)] is prime by construction.
112, for instance, is not prime but 211 is. The same for 334 (composite) and 433 (prime), or 956 (composite) and 659 (prime). 7910 is not prime, but (0)197 is prime. If both concatenations are prime, we keep the smallest term.
PROG
(Python)
from sympy import isprime
from itertools import count, islice
def c(s, t, u): return isprime(int(s+t+u)) or isprime(int(u+t+s))
def agen(): # generator of terms
an, aset, m = 1, set(), 2
for n in count(1):
yield an
aset.add(an)
s, t = str(an), str(n)
an = next(k for k in count(m) if k not in aset and c(s, t, str(k)))
while m in aset: aset.discard(m); m += 1
print(list(islice(agen(), 70)))
CROSSREFS
Cf. A000040.
Sequence in context: A060866 A064478 A111798 * A249543 A307404 A307405
KEYWORD
base,nonn
AUTHOR
STATUS
approved