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.

A164968 Naughty primes: primes in which the number of zeros is greater than the number of all other digits.

Original entry on oeis.org

10007, 10009, 40009, 70001, 70003, 70009, 90001, 90007, 100003, 200003, 200009, 300007, 400009, 500009, 700001, 900001, 900007, 1000003, 1000033, 1000037, 1000039, 1000081, 1000099, 1000303, 1000403, 1000409, 1000507, 1000609, 1000907, 1001003, 1003001
Offset: 1

Views

Author

G. L. Honaker, Jr., Sep 02 2009

Keywords

Comments

a(31) = 1003001 is the smallest palindromic naughty prime. - M. F. Hasler, Nov 22 2009
This sequence can be considered as irregular table in which row n lists the terms with n digits. The row lengths (number of terms with n digits) are then 0, 0, 0, 0, 8, 9, 296, 275, 7934, 9527, 235729, ... - M. F. Hasler, Jul 13 2018

Examples

			a(24) = 1000303 is a naughty prime because the number of zeros is greater than the number of all other digits.
		

Programs

  • Maple
    Q[1]:= [seq([i],i=1..9)]:
    for d from 2 to 6 do Q[d]:= map(t -> seq([i,op(t)],i=1..9),Q[d-1]) od:
    F:= proc(d) local R,dn,s,sp,q,x;
       R:= NULL;
       for dn from 2 to floor((d-1)/2) do
          for s in combinat:-choose([$1..d-2],dn-2) do
            sp:= [0,op(s),d-1];
            for q in Q[dn] do
              x:= add(q[i]*10^sp[i],i=1..dn);
              if isprime(x) then R:= R, x fi;
        od od od;
        sort([R])
    end proc:
    seq(op(F(d)),d=5..7); # Robert Israel, Jul 10 2018
  • Mathematica
    lst = {}; Do[If[PrimeQ[n] && Count[IntegerDigits[n], 0] > IntegerLength[n]/2, AppendTo[lst, n]], {n, 10^4 + 1, 3^13, 2}]; lst (* Arkadiusz Wesolowski, Sep 18 2011 *)
    Select[Prime[Range[100000]],DigitCount[#,10,0]>IntegerLength[#]/2&] (* Harvey P. Dale, Jun 09 2015 *)
  • PARI
    next_A164968(p)={ for( n=#Str(p)\2+1,oo, my(L=10^(2*n+1)); p=max(10^(2*n-3),p); while( L>p=nextprime(p+1), vecsort(Vecsmall(Str(p)))[n]>48 || return(p));p=0) } \\ M. F. Hasler, Nov 22 2009, syntax update Jul 10 2018
    
  • PARI
    A164968_row(n, a=List(), t=vectorv(n, i, 10^(n-i)))={for(z=2, (n-1)\2, my(v=vector(z, i, if(i<2, [1, 1], iM. F. Hasler, Jul 13 2018
    
  • Python
    from sympy import isprime
    from itertools import combinations, count, islice, product
    def agen(): # generator of terms
        for d in count(5):
            for first in "123456789":
                passed = set()
                for last in "1379":
                    for znum in range(d//2 + 1, d-1):
                        for zlocs in combinations(range(d-2), znum):
                            for rest in product("123456789", repeat=d-2-znum):
                                nzi, middle = 0, []
                                for i in range(d-2):
                                    if i in zlocs:
                                        middle.append("0")
                                    else:
                                        middle.append(rest[nzi])
                                        nzi += 1
                                t = int("".join(first + "".join(middle) + last))
                                if isprime(t):
                                    passed.add(t)
                yield from sorted(passed)
    print(list(islice(agen(), 31))) # Michael S. Branicky, Mar 11 2022