OFFSET
1,1
COMMENTS
Primes n with an even number of digits are included if (a) a prime results after reversing n's digits by pairs, e.g., 8971 is a prime and is included because 9817 is also a prime, and (b) n's second digit is not zero. Primes with an odd number of digits are included if (a) a prime results after extracting the middle digit of n, reversing the rest of n's digits by pairs, and inserting the middle digit of n back into the middle of the resulting digits, e.g., 1358471 is a prime and is included because 3148517 is also a prime, and (b) n's second digit is not zero.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
MATHEMATICA
dsdQ[n_/; EvenQ[IntegerLength[n]]]:=Module[{idn=IntegerDigits[n]}, idn[[2]] != 0&&PrimeQ[FromDigits[Flatten[Reverse/@Partition[idn, 2]]]]]; dsdQ[ n_/; OddQ[ IntegerLength[n]]]:=Module[{idn=IntegerDigits[n], len = (IntegerLength[ n]-1)/2, t, fr, ls, md}, t=TakeDrop[idn, len]; fr=t[[1]]; ls=Rest[ t[[2]]]; md=First[t[[2]]]; idn[[2]]!=0&&PrimeQ[FromDigits[ Insert[ Flatten[Reverse/@Partition[Join[fr, ls], 2]], md, len+1]]]]; Select[Prime[Range[5, 500]], dsdQ] (* The program uses the TakeDrop function from Mathematica version 10 *)
PROG
(Perl) use ntheory ":all"; sub is_a266675 { my $n = shift; my @d=todigits($n); return unless is_prime($n) && $d[1] != 0; my $middle = (@d & 1) ? splice(@d, @d>>1, 1) : undef; my @r = @d[map {$_^1} 0..$#d]; splice(@r, @r>>1, 0, $middle) if defined $middle; is_prime(fromdigits(\@r)); } # Dana Jacobsen, Jan 03 2016
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Harvey P. Dale, Jan 02 2016
STATUS
approved