cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A138584 Palindromic primes using only digits 3 and 5.

This page as a plain text file.
%I A138584 #27 Jun 18 2025 21:49:28
%S A138584 3,5,353,33533,35353,3353533,3553553,333535333,335333533,355353553,
%T A138584 355555553,33335353333,33553335533,35533333553,35553535553,
%U A138584 3335535355333,3335555555333,3353353533533,3353355533533,3355535355533,3533355533353,3533533353353
%N A138584 Palindromic primes using only digits 3 and 5.
%H A138584 Chai Wah Wu, <a href="/A138584/b138584.txt">Table of n, a(n) for n = 1..5382</a>
%p A138584 revdigs:= proc(n) option remember;
%p A138584     local b;
%p A138584     if n < 10 then return n fi;
%p A138584     b:= n mod 10;
%p A138584     b*10^ilog10(n) + procname((n-b)/10);
%p A138584 end proc:
%p A138584 A:= {3,5}:
%p A138584 B:= [0]:
%p A138584 for d from 2 to 20 do
%p A138584   if d::even then
%p A138584     B:= map(t -> (10*t+3,10*t+5), B);
%p A138584     A:= A union select(isprime, {seq(revdigs(b)+10^(d/2)*b,b=B)});
%p A138584   else
%p A138584     A:= A union select(isprime, {seq(seq(
%p A138584          revdigs(b)+i*10^((d-1)/2)+10^((d+1)/2)*b, i = [3,5]),b=B)});
%p A138584   fi
%p A138584 od:
%p A138584 sort(convert(A,list)); # _Robert Israel_, Dec 17 2015
%t A138584 RevDigs[n_] := Module[{b}, If[n < 10, Return[n]];  b = Mod[n, 10]; b * 10^Floor[Log10[n]] + RevDigs[(n - b)/10]];A = {3, 5};B = {0};Do[  If[EvenQ[d], B = Flatten[Map[{10*# + 3, 10*# + 5} &, B]]; A = Union[A, Select[Map[RevDigs[#] + 10^(d/2)*# &, B], PrimeQ, Infinity]], A = Union[A, Select[Flatten[Table[RevDigs[b] + i*10^((d-1)/2) + 10^((d+1)/2)*b, {b, B}, {i, {3, 5}}]], PrimeQ, Infinity]];  ],  {d, 2, 20}];Sort[A] (* _James C. McMahon_, Jun 13 2025 *)
%o A138584 (Python)
%o A138584 from itertools import product
%o A138584 from sympy import isprime
%o A138584 A138584_list = []
%o A138584 for l in range(17):
%o A138584     for d in product('35',repeat=l):
%o A138584         s = ''.join(d)
%o A138584         n = int(s+'3'+s[::-1])
%o A138584         if isprime(n):
%o A138584             A138584_list.append(n)
%o A138584         n += 2*10**l
%o A138584         if isprime(n):
%o A138584             A138584_list.append(n) # _Chai Wah Wu_, Dec 17 2015
%Y A138584 Cf. A020462.
%K A138584 nonn,base
%O A138584 1,1
%A A138584 _Paul Curtz_, May 13 2008
%E A138584 More terms from _Arkadiusz Wesolowski_, Dec 31 2011