login
Primes such that a sum of any two adjacent digits is prime; first and last digits are considered adjacent.
3

%I #18 Oct 27 2023 20:43:29

%S 11,23,29,41,43,47,61,67,83,89,211,2029,2111,2129,2141,2143,2161,2341,

%T 2383,2389,2503,2521,4111,4129,4349,4703,4943,6121,6521,6761,8329,

%U 8389,8923,8929,11161,11411,12161,12941,14321,14341,14741,16111,16141,16561,16741,20323,20341,20389,20521

%N Primes such that a sum of any two adjacent digits is prime; first and last digits are considered adjacent.

%C Each (2- or more-digit) term must begin with one of the even digits 2,4,6,8 or else must begin and end with the digit 1. All repunit primes (A004022) are terms as the sums are always 2.

%H Alois P. Heinz, <a href="/A086244/b086244.txt">Table of n, a(n) for n = 1..10000</a> (first 623 terms from Zak Seidov)

%e 2029 is a term because it is a prime and 2+0, 0+2, 2+9, 9+2 are all primes.

%t p=10; Reap[Do[Label[ne]; p=NextPrime[p]; id=IntegerDigits[p];

%t id1=Append[id,id[[1]]];id2=Prepend[id,id[[-1]]];

%t If[{True}==Union[PrimeQ[id1+id2]],Sow[p]], {2000}]][[2, 1]]

%t (* _Zak Seidov_, May 10 2016 *)

%t tadpQ[n_]:=Module[{idn=IntegerDigits[n]},AllTrue[ Join[{idn[[1]]+ idn[[-1]]}, Total/@Partition[idn,2,1]],PrimeQ]]; Select[Prime[Range[ 2500]],tadpQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Jun 08 2019 *)

%K easy,base,nonn

%O 1,1

%A _Zak Seidov_, Jul 13 2003

%E Corrected and extended by _Rick L. Shepherd_, Feb 11 2004