login
A266675
Do-si-do primes: primes that remain prime when their digits, taken by pairs, are reversed (see comments for more details).
1
11, 13, 17, 31, 37, 71, 73, 79, 97, 113, 131, 149, 151, 157, 167, 179, 181, 191, 199, 311, 313, 337, 347, 353, 359, 373, 383, 389, 727, 733, 739, 743, 751, 757, 761, 769, 787, 797, 919, 929, 937, 941, 953, 967, 971, 983, 991, 1117, 1171, 1213, 1231, 1297
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
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
Sequence in context: A111337 A359136 A359137 * A185104 A240570 A354524
KEYWORD
nonn,base
AUTHOR
Harvey P. Dale, Jan 02 2016
STATUS
approved