OFFSET
1,2
COMMENTS
The sequence is a rearrangement of the positive integers.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
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
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Michael S. Branicky, Aug 08 2024
STATUS
approved