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.

A018847 Strobogrammatic primes: the same upside down (calculator-style numerals).

Original entry on oeis.org

2, 5, 11, 101, 151, 181, 619, 659, 6229, 10501, 12821, 15551, 16091, 18181, 19861, 60209, 60509, 61519, 61819, 62129, 116911, 119611, 160091, 169691, 191161, 196961, 605509, 620029, 625529, 626929, 650059, 655559, 656959, 682289, 686989, 688889
Offset: 1

Views

Author

Keywords

Comments

This is the subsequence of primes in A018846. - M. F. Hasler, May 05 2012

Crossrefs

Cf. A007597 (more restrictive version not allowing digits 2 or 5).

Programs

  • Mathematica
    lst = {}; fQ[n_] := Block[{allset = {0, 1, 2, 5, 6, 8, 9}, id = IntegerDigits@n}, Union@ Join[id, allset] == allset && Reverse[id /. {6 -> 9, 9 -> 6}] == id]; Do[ If[ PrimeQ@n && fQ@n, AppendTo[lst, n]], {n, 700000}]; lst (* Robert G. Wilson v, Feb 27 2007 *)
  • PARI
    {write("/tmp/b018847.txt","1 2\n2 5"); c=2; s2=[0,1,2,5,6,8,9]; s=[0,1,2,5,8]; s1=[0,1,2,5,9,8,6]; for(n=2,9, p1=vector( (n+1)\2, i, 10^(i-1)); p2=vector( (n+1)\2, i, 10^(n-i)); forvec( v=vector((n+1)\2,i,if( i>1, [ 1,if( i>n\2, #s, #s1)], [2,5])), v[1]==3 & v[1]=5; ispseudoprime( t=sum(i=1,n\2,p1[i]*s1[v[i]]+p2[i]*s2[v[i]] ) +if(n%2,p1[#p1]*s[v[#v]] )) & /* print1(t",") */ write("/tmp/b018847.txt",c++" "t)))} \\ - M. F. Hasler, Apr 26 2012
    
  • PARI
    is_A018847(n,t=Vec("012..59.86"))={ isprime(n) & apply(x->t[eval(x)+1], n=Vec(Str(n)))==vecextract(n, "-1..1") } \\ - M. F. Hasler, May 05 2012
    
  • Python
    from itertools import count, islice
    from sympy import isprime
    def A018847_gen(): # generator of terms
        r, t, u = ''.maketrans('69','96'), set('0125689'), {0,1,2,5,8}
        for x in count(1):
            for y in range(10**(x-1),10**x):
                if y%10 in u:
                    s = str(y)
                    if set(s) <= t and isprime(m:=int(s+s[-2::-1].translate(r))):
                        yield m
            for y in range(10**(x-1),10**x):
                s = str(y)
                if set(s) <= t and isprime(m:=int(s+s[::-1].translate(r))):
                    yield m
    A018847_list = list(islice(A018847_gen(),20)) # Chai Wah Wu, Apr 09 2024