A096246 Base-2 deletable primes (written in base 10).
2, 3, 5, 7, 11, 13, 19, 23, 29, 37, 43, 47, 53, 59, 61, 73, 79, 83, 101, 107, 109, 137, 149, 151, 157, 163, 167, 173, 179, 197, 211, 229, 277, 281, 293, 307, 311, 313, 317, 331, 347, 349, 359, 389, 397, 419, 421, 457, 461, 467, 557, 563, 569, 587, 599, 601, 613
Offset: 1
Links
- Lei Zhou, Table of n, a(n) for n = 1..10000
Programs
-
Maple
isDel := proc(n::integer) local b2,redu,rpr,d; if n = 2 or n =3 then RETURN(true); elif not isprime(n) then RETURN(false); else b2 := convert(n,base,2); for d from 1 to nops(b2) do redu := [op(1..d-1,b2),op(d+1..nops(b2),b2) ]; if op(nops(redu),redu) = 1 then rpr := sum( op(i,redu)*2^(i-1),i=1..nops(redu)); if isDel(rpr) then RETURN(true); fi; fi; od; RETURN(false); fi; end: for n from 1 to 200 do if isDel(ithprime(n)) then printf("%d,",ithprime(n)); fi; od: # R. J. Mathar, Apr 25 2006
-
Mathematica
a = {}; c = {1}; While[Length[a] < 100, b = c; c = {}; lb = Length[b]; Do[nb = b[[ib]]; cdb = RealDigits[nb, 2]; db = cdb[[1]]; ldb = cdb[[2]]; Do[dc = Insert[db, 0, j]; nc = FromDigits[dc, 2]; If[PrimeQ[nc], AppendTo[c, nc]], {j, 2, ldb + 1}]; Do[dc = Insert[db, 1, j]; nc = FromDigits[dc, 2]; If[PrimeQ[nc], AppendTo[c, nc]], {j, 2, ldb + 1}], {ib, 1, lb}]; c = Union[{}, c]; a = Union[a, c]]; a (* Lei Zhou, Mar 06 2015 *) a = {0, 2}; d = {2, 3}; For[n = 3, n <= 15, n++, p = Select[Range[2^(n - 1), 2^n - 1], PrimeQ[#] &]; For[i = 1, i <= Length[p], i++, c = IntegerDigits[p[[i]], 2]; For[j = 1, j <= n, j++, t = Delete[c, j]; If[t[[1]] == 0, Continue[]]; If[MemberQ[d, FromDigits[t, 2]], AppendTo[d, p[[i]]]; Break[]]]]]; d (* Robert Price, Nov 11 2018 *)
-
Python
from sympy import isprime def ok(n): if not isprime(n): return False if n == 2 or n == 3: return True b = bin(n)[2:] bi = (b[:i]+b[i+1:] for i in range(len(b))) return any(t[0] != '0' and ok(int(t, 2)) for t in bi) print([k for k in range(614) if ok(k)]) # Michael S. Branicky, Jan 13 2022
Extensions
More terms from R. J. Mathar, Apr 25 2006
Comments