login
Numbers n such that n and n + 1 are both composite and the reverse of n and n + 1 are both prime.
1

%I #35 Aug 10 2017 13:03:22

%S 34,91,118,124,133,145,300,361,364,370,376,391,721,730,745,754,763,

%T 775,778,784,790,904,916,931,943,973,994,1003,1015,1075,1081,1084,

%U 1099,1105,1126,1138,1189,1204,1255,1261,1324,1348,1351,1393,1444,1477

%N Numbers n such that n and n + 1 are both composite and the reverse of n and n + 1 are both prime.

%C Related to a palindrome, a semordnilap is a word that when reversed results in a new, different, valid word. For example the semordnilap of the word "desserts" is the word "stressed". Applying this principle to numbers, any number is either a palindrome or a semordnilap. This sequence deals with adjacent composite numbers whose semordnilap numbers are prime.

%H Charles R Greathouse IV, <a href="/A282811/b282811.txt">Table of n, a(n) for n = 1..10000</a>

%e For n = 2 * 17 = 34, which reverses to 43, a prime, we have n + 1 = 5 * 7 = 35, which reverses to 53, also a prime.

%t searchMax = 2000; Select[Complement[Range[searchMax], Prime[Range[PrimePi[searchMax]]]], Not[PrimeQ[# + 1]] && PrimeQ[FromDigits[Reverse[IntegerDigits[#]]]] && PrimeQ[FromDigits[Reverse[IntegerDigits[# + 1]]]] &] (* _Alonso del Arte_, Feb 23 2017 *)

%t Select[Partition[Range[1500],2,1],AllTrue[#,CompositeQ] && AllTrue[ IntegerReverse[#],PrimeQ]&][[All,1]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Aug 10 2017 *)

%o (PARI) rev(n)=fromdigits(Vecrev(digits(n)))

%o is(n)=isprime(rev(n)) && isprime(rev(n+1)) && !isprime(n) && !isprime(n+1) \\ _Charles R Greathouse IV_, Feb 23 2017

%K nonn,base

%O 1,1

%A _Philip Mizzi_, Feb 22 2017