login
Antipalindromic primes: primes with an even number of digits such that the digits in the first half of the prime differ from the corresponding digits of the second half.
1

%I #21 Jun 18 2024 02:03:59

%S 13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,1013,

%T 1019,1033,1039,1049,1063,1069,1087,1093,1097,1103,1109,1123,1129,

%U 1153,1163,1187,1193,1213,1217,1237,1249,1259,1277,1279,1283,1289,1297,1303,1307

%N Antipalindromic primes: primes with an even number of digits such that the digits in the first half of the prime differ from the corresponding digits of the second half.

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

%H C. Caldwell and H. Dubner (Eds), <a href="https://t5k.org/lists/top_ten/">The top ten prime numbers: from the unpublished collections of R. Ondrejka</a> (May 2001), p. 6.

%p filter:= proc(n) local L,LR;

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

%p if nops(L)::odd

%p then return false

%p fi;

%p L:= ListTools:-Reverse(L) - L;

%p not has(L,0);

%p end;

%p Primes:= [seq(op(select(isprime,[$10^(2*n-1) ... 10^(2*n)-1])),n=1..3)]:

%p A241059:= select(filter,Primes); # _Robert Israel_, Apr 17 2014

%o (PARI) for(n=1, 1307, s=#Str(n); if(!bitand(s, 1)&&isprime(n), t=0; v=Vec(Str(n)); for(k=1, s/2, if(v[k]==v[s+1-k], break, t++)); if(t==s/2, print1(n, ", "))));

%o (Python)

%o from sympy import isprime

%o def ok(n):

%o s = str(n)

%o return not len(s)&1 and all(s[i] != s[-1-i] for i in range(len(s)//2)) and isprime(n)

%o print([k for k in range(2000) if ok(k)]) # _Michael S. Branicky_, Jun 17 2024

%K nonn,base

%O 1,1

%A _Arkadiusz Wesolowski_, Apr 15 2014