%I #13 May 09 2022 15:12:30
%S 2,1,3,4,5,6,8,7,40,9,13,46,20,10,15,21,30,18,17,42,32,19,34,23,44,25,
%T 29,38,48,45,60,62,50,64,52,56,63,80,66,68,70,82,58,74,69,76,84,81,87,
%U 401,86,88,100,90,93,201,91,95,200,96,99,97,406,204,206,208,101,300
%N If a(n) is prime, then a(n) + a(n+1) is prime; if a(n) is not prime, then a(n) + a(n+1) is not prime. This is also true for pairs of consecutive digits: if the first one is prime, the sum of the pair is also prime; if the first one is nonprime, the sum of the pair is nonprime. This is the lexicographically earliest sequence of distinct terms > 0 with this property.
%e a(1) = 2 (prime) and a(1) + a(2) = 2 + 1 = 3 [which is prime, like a(1)];
%e a(2) = 1 (nonprime) and a(2) + a(3) = 1 + 3 = 4 [which is nonprime, like a(2)];
%e a(3) = 3 (prime) and a(3) + a(4) = 3 + 4 = 7 [which is prime, like a(3)];
%e a(4) = 4 (nonprime) and a(4) + a(5) = 4 + 5 = 9 [which is nonprime, like a(4)];
%e a(5) = 5 (prime) and a(5) + a(6) = 5 + 6 = 11 [which is prime, like a(5)];
%e (...)
%e a(8) = 7 (prime) and a(8) + a(9) = 7 + 40 = 47 [which is prime, like a(8)];
%e now we have to consider also the digits of the pair (7,4); they are "7", the last digit of a(8), and "4", the first digit of a(9): as the first digit of the pair is prime (7), the sum of this 7 and the next digit (4) has to be prime too, which is the case, 4 + 7 = 11;
%e a(9) = 40 (nonprime) and a(9) + a(10) = 40 + 9 = 49 [which is nonprime, like a(9)];
%e the next pair of digits we have to consider after (7,4) is (4,0); as 4 is nonprime, so has to be the sum 4 + 0 (which is the case as 4 + 0 = 4); etc.
%t t[x_,y_]:=If[PrimeQ@x,PrimeQ[x+y],!PrimeQ[x+y]];a[1]=2;a[n_]:=a[n]=Block[{k=1},While[MemberQ[Array[a,n-1],k]||!And@@(t@@@Partition[Flatten[IntegerDigits/@Join[Array[a,n-1],{k}]],2,1])||!t@@{a[n-1],k},k++];k];Array[a,68] (* _Giorgos Kalogeropoulos_, May 09 2022 *)
%Y Cf. A219110.
%K base,nonn
%O 1,1
%A _Eric Angelini_ and _Carole Dubois_, Aug 03 2021