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.

Original entry on oeis.org

3, 5, 353, 33533, 35353, 3353533, 3553553, 333535333, 335333533, 355353553, 355555553, 33335353333, 33553335533, 35533333553, 35553535553, 3335535355333, 3335555555333, 3353353533533, 3353355533533, 3355535355533, 3533355533353, 3533533353353
Offset: 1

Views

Author

Paul Curtz, May 13 2008

Keywords

Crossrefs

Cf. A020462.

Programs

  • Maple
    revdigs:= proc(n) option remember;
        local b;
        if n < 10 then return n fi;
        b:= n mod 10;
        b*10^ilog10(n) + procname((n-b)/10);
    end proc:
    A:= {3,5}:
    B:= [0]:
    for d from 2 to 20 do
      if d::even then
        B:= map(t -> (10*t+3,10*t+5), B);
        A:= A union select(isprime, {seq(revdigs(b)+10^(d/2)*b,b=B)});
      else
        A:= A union select(isprime, {seq(seq(
             revdigs(b)+i*10^((d-1)/2)+10^((d+1)/2)*b, i = [3,5]),b=B)});
      fi
    od:
    sort(convert(A,list)); # Robert Israel, Dec 17 2015
  • Mathematica
    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 *)
  • Python
    from itertools import product
    from sympy import isprime
    A138584_list = []
    for l in range(17):
        for d in product('35',repeat=l):
            s = ''.join(d)
            n = int(s+'3'+s[::-1])
            if isprime(n):
                A138584_list.append(n)
            n += 2*10**l
            if isprime(n):
                A138584_list.append(n) # Chai Wah Wu, Dec 17 2015

Extensions

More terms from Arkadiusz Wesolowski, Dec 31 2011