A228323 a(1)=1; thereafter a(n) is the smallest number m not yet in the sequence such that at least one of the concatenations a(n-1)||m or m||a(n-1) is prime.
1, 3, 2, 9, 5, 21, 4, 7, 6, 13, 10, 19, 16, 27, 8, 11, 15, 23, 12, 17, 20, 29, 14, 33, 26, 47, 18, 31, 25, 39, 22, 37, 24, 41, 30, 49, 34, 57, 28, 43, 36, 59, 32, 51, 38, 53, 42, 61, 45, 67, 58, 69, 55, 63, 44, 81, 35, 71, 48, 77, 50, 87, 62, 99, 40, 73, 46
Offset: 1
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
- Eric Angelini, Primes by concatenation, Posting to the Sequence Fans Mailing List, Aug 14 2013.
- Michael De Vlieger, Labeled log-log scatterplot of a(n) n = 1..2^14, showing m coprime to 10 in red, otherwise dark blue.
- Index entries for primes involving decimal expansion of n
Programs
-
Mathematica
f[s_] := Block[{k = 2, idj = IntegerDigits@ s[[-1]]}, While[idk = IntegerDigits@ k; MemberQ[s, k] || ( !PrimeQ@ FromDigits@ Join[idj, idk] && !PrimeQ@ FromDigits@ Join[idk, idj]), k++]; Append[s, k]]; Nest[f, {1}, 66] (* Robert G. Wilson v, Aug 20 2013 *)
-
Python
from sympy import isprime from itertools import islice def c(s, t): return isprime(int(s+t)) or isprime(int(t+s)) def agen(): aset, k, mink = set(), 1, 2 while True: an = k; aset.add(an); yield an; s, k = str(an), mink while k in aset or not c(s, str(k)): k += 1 while mink in aset: mink += 1 print(list(islice(agen(), 56))) # Michael S. Branicky, Oct 17 2022
Extensions
More terms from Alois P. Heinz, Aug 20 2013
Comments