login
A029971
Palindromic primes in base 3.
12
2, 13, 23, 151, 173, 233, 757, 937, 1093, 1249, 1429, 1487, 1667, 1733, 1823, 1913, 1979, 2069, 8389, 9103, 10111, 12301, 14951, 16673, 16871, 18593, 60103, 60913, 61507, 63127, 69697, 73243, 78979, 80599, 82003, 82813, 83407, 85027
OFFSET
1,1
COMMENTS
Intersection of A000040 and A014190. - Michel Marcus, Aug 19 2015
MAPLE
N:= 14: # to get all terms < 3^N
Res:= 2:
digrev:=proc(n) local L;
L:= convert(n, base, 3);
add(L[-i]*3^(i-1), i=1..nops(L))
end proc;
for d from 2 to N do
if d::even then
m:= d/2;
Res:= Res, op(select(isprime, [seq](n*3^m + digrev(n), n=3^(m-1)..3^m-1)));
else
m:= (d-1)/2;
Res:= Res, op(select(isprime, [seq](seq(n*3^(m+1)+y*3^m+digrev(n),
y=0..2), n=3^(m-1)..3^m-1)));
fi
od:
Res; # Robert Israel, Aug 19 2015
MATHEMATICA
Do[s = RealDigits[n, 3][[1]]; If[PrimeQ[n], If[FromDigits[s] == FromDigits[Reverse[s]], Print[n]]], {n, 1, 8500}]
Select[Prime[Range[8300]], Reverse[x = IntegerDigits[#, 3]] == x &] (* Jayanta Basu, Jun 23 2013 *)
PROG
(PARI) lista(nn) = forprime(p=2, nn, if ((d=digits(p, 3)) && (Vecrev(d)==d), print1(p, ", "))); \\ Michel Marcus, Aug 19 2015
CROSSREFS
Cf. A117698 (in base 3), A014190.
Sequence in context: A093301 A079397 A118524 * A243619 A243620 A090526
KEYWORD
nonn,base
STATUS
approved