Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #19 Nov 07 2022 13:46:14
%S 1,3,4,7,19,31,67,391,583,4549,917467,6777061,86794921,1421517037,
%T 171234891469
%N Lexicographically earliest sequence of distinct terms such that, when i<j, at least one of a(i) U a(j) or a(j) U a(i) is prime (where U denotes concatenation).
%C Two distinct terms can always be concatenated in some way to form a prime number.
%C Is this sequence infinite?
%H Paul Tek, <a href="/A246805/a246805.gp.txt">PARI program for this sequence</a>
%e The following concatenations are prime:
%e - j=2: a(1) U a(2)=13, a(2) U a(1)=31
%e - j=3: a(3) U a(1)=41, a(3) U a(2)=43
%e - j=4: a(1) U a(4)=17, a(4) U a(1)=71, a(2) U a(4)=37, a(4) U a(2)=73, a(3) U a(4)=47
%e - j=5: a(5) U a(1)=191, a(5) U a(2)=193, a(3) U a(5)=419, a(4) U a(5)=719, a(5) U a(4)=197
%e - j=6: a(1) U a(6)=131, a(6) U a(1)=311, a(2) U a(6)=331, a(6) U a(2)=313, a(3) U a(6)=431, a(6) U a(4)=317, a(5) U a(6)=1931, a(6) U a(5)=3119
%o (PARI) See Link section.
%o (Python)
%o from sympy import isprime
%o from itertools import islice
%o def c(s, slst):
%o return all(isprime(int(s+t)) or isprime(int(t+s)) for t in slst)
%o def agen():
%o slst, an, mink = [], 1, 2
%o while True:
%o yield an; slst.append(str(an)); an += 1
%o while not c(str(an), slst): an += 1
%o print(list(islice(agen(), 10))) # _Michael S. Branicky_, Oct 17 2022
%Y Cf. A156770, A228323.
%K base,nonn,more
%O 1,2
%A _Paul Tek_, Nov 16 2014
%E a(15) from _Michael S. Branicky_, Nov 07 2022