login
Sums of two consecutive primes whose reversal is also the sum of two consecutive primes.
1

%I #25 Oct 02 2022 13:29:23

%S 5,8,24,42,210,222,240,258,288,434,480,630,696,810,828,852,882,2100,

%T 2112,2580,2610,2640,2728,2740,2780,2886,2904,2992,4056,4092,4224,

%U 4260,4268,4296,4340,4410,4458,4476,4554,4680,4688,4698,4860,6078,6090,6300,6336,6378,6504,6690,6720,6744,6798

%N Sums of two consecutive primes whose reversal is also the sum of two consecutive primes.

%C Members k of A001043 such that A004086(k) is in A001043.

%C If k is in the sequence and does not end in 0, then the reversal of k is also in the sequence.

%H Robert Israel, <a href="/A357117/b357117.txt">Table of n, a(n) for n = 1..10000</a>

%e a(5) = 210 is a member because 210 = 103+107 where 103 and 107 are consecutive primes, and its reversal 12 = 5+7 where 5 and 7 are consecutive primes.

%p rev:= proc(n) local L,i;

%p L:= convert(n,base,10);

%p add(L[-i]*10^(i-1),i=1..nops(L));

%p end proc:

%p P:= select(isprime, [2,seq(i,i=3..50000,2)]):

%p P2:= convert(P[1..-2]+P[2..-1],set):

%p A:= sort(convert(select(t -> member(rev(t),P2), P2),list));

%t g = {}; For[m = 1, m <= 6800, m++ , n = FromDigits[Reverse[IntegerDigits[m]]]; If[NextPrime[(m + 1)/2, -1] + NextPrime[(m - 1)/2] == m && !PrimeQ[m/2] && NextPrime[(n + 1)/2, -1] + NextPrime[(n - 1)/2] == n && !PrimeQ[n/2], AppendTo[g, m]]]; Print[g] (* _Samuel Harkness_, Sep 19 2022 *)

%o (Python)

%o from itertools import islice

%o from sympy import isprime, nextprime, prevprime

%o def isA001043(n):

%o if n < 6: return n == 5

%o h = n//2

%o return not isprime(h) and n == prevprime(h) + nextprime(h)

%o def agen():

%o p, q, s = 2, 3, 5

%o while True:

%o if isA001043(int(str(s)[::-1])): yield s

%o p, q = q, nextprime(q); s = p+q

%o print(list(islice(agen(), 53))) # _Michael S. Branicky_, Sep 19 2022

%Y Cf. A001043, A004086. Contains A162571.

%K nonn,base

%O 1,1

%A _J. M. Bergot_ and _Robert Israel_, Sep 18 2022