A087155 Primes having nontrivial palindromic representation in some (at least one) base.
5, 7, 13, 17, 23, 29, 31, 37, 41, 43, 59, 61, 67, 71, 73, 83, 89, 97, 101, 107, 109, 113, 127, 131, 151, 157, 173, 181, 191, 193, 197, 199, 211, 227, 229, 233, 239, 241, 251, 257, 271, 277, 281, 307, 313, 331, 337, 349, 353, 373, 379, 383, 397, 401, 409, 419
Offset: 1
Examples
17 is in the list because 17_2 = 10001 and 17_4 = 101, two nontrivial palindromic representations. 19 is not in the list because 19 is not a multidigit palindrome in any base other than base 18.
Links
- Robert G. Wilson v, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A016038.
Programs
-
Maple
filter:= proc(n) local b,L; if not isprime(n) then return false fi; for b from 2 to floor(sqrt(n)) do L:= convert(n,base,b); if L = ListTools:-Reverse(L) then return true fi; od: false end proc: select(filter, [2*i+1 $ i=1..1000]); # Robert Israel, Jul 27 2015
-
Mathematica
palindromicBases[n_] := Module[{p}, Table[p = IntegerDigits[n, b]; If[p == Reverse[p], {b, p}, Sequence @@ {}], {b, 2, n - 2}]]; Select[ Prime@ Range@ 300, palindromicBases[#] !={}&] (* Robert G. Wilson v, May 06 2014 *)
-
PARI
q=1; forprime(m=3,500,count=0; for(b=2,m-1, w=b+1; k=0; i=m; while(i>0,k=k*w+i%b; i=floor(i/b)); l=0; j=k; while(j>0,l=l*w+j%w; j=floor(j/w)); if(l==k,count=count+1; if(count>1,print1(m,", "); q=b; m=nextprime(m+1); q=1; b=1,q=b),)))
Extensions
Title, comments and example changed to agree with convention on single-digit numbers and incorporate 'nontrivial' concept by James G. Merickel, Jul 25 2015
Comments