login
A096237
Number of n-digit base-4 deletable primes.
0
2, 3, 9, 26, 75, 213, 615, 1853, 5854, 18664, 61248, 205300, 698575, 2409598, 8408050, 29657194
OFFSET
1,1
COMMENTS
A prime p is a base-b deletable prime if when written in base b it has the property that removing some digit leaves either the empty string or another deletable prime. "Digit" means digit in base b.
Deleting a digit cannot leave any leading zeros in the new string. For example, deleting the 2 in 2003 to obtain 003 is not allowed.
MATHEMATICA
b = 4; a = {2}; d = {2, 3};
For[n = 2, n <= 8, n++,
p = Select[Range[b^(n - 1), b^n - 1], PrimeQ[#] &];
ct = 0;
For[i = 1, i <= Length[p], i++,
c = IntegerDigits[p[[i]], b];
For[j = 1, j <= n, j++,
t = Delete[c, j];
If[t[[1]] == 0, Continue[]];
If[MemberQ[d, FromDigits[t, b]], AppendTo[d, p[[i]]]; ct++;
Break[]]]];
AppendTo[a, ct]];
a (* Robert Price, Nov 12 2018 *)
PROG
(Python)
from sympy import isprime
from sympy.ntheory.digits import digits
def ok(n, prevset, base=4):
if not isprime(n): return False
s = "".join(str(d) for d in digits(n, base)[1:])
si = (s[:i]+s[i+1:] for i in range(len(s)))
return any(t[0] != '0' and int(t, base) in prevset for t in si)
def afind(terms):
alst = [2]
s, snxt, base = {2, 3}, set(), 4
print(len(s), end=", ")
for n in range(2, terms+1):
for i in range(base**(n-1), base**n):
if ok(i, s):
snxt.add(i)
s, snxt = snxt, set()
print(len(s), end=", ")
afind(10) # Michael S. Branicky, Jan 17 2022
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Michael Kleber, Feb 28 2003
EXTENSIONS
a(6)-a(15) from Ryan Propper, Jul 19 2005
a(16) from Michael S. Branicky, Jan 17 2022
STATUS
approved