A267413 Dropping any binary digit gives a prime number.
6, 7, 11, 15, 35, 39, 63, 135, 255, 999, 2175, 8223, 16383, 57735, 131075, 131079, 262143, 524295, 1048575, 536870919, 1073735679, 2147483655, 4294967295, 17179770879, 4260641103903, 4611686018427387903, 4720069647059686260735, 1237940039285380274899124223
Offset: 1
Examples
Decimal and binary forms of the known terms: 1 6 110 2 7 111 3 11 1011 4 15 1111 5 35 100011 6 39 100111 7 63 111111 8 135 10000111 9 255 11111111 10 999 1111100111 11 2175 100001111111 12 8223 10000000011111 13 16383 11111111111111 14 57735 1110000110000111 <--- (a binary palindrome 15 131075 100000000000000011 with 5 digit runs) 16 131079 100000000000000111 17 262143 111111111111111111 18 524295 10000000000000000111 19 1048575 11111111111111111111 20 536870919 100000000000000000000000000111 21 1073735679 111111111111111110011111111111 22 2147483655 10000000000000000000000000000111 23 4294967295 11111111111111111111111111111111 24 17179770879 1111111111111111100111111111111111
Programs
-
Maple
filter:= proc(n) local B,k,y; if not isprime(floor(n/2)) then return false fi; B:= convert(n,base,2); for k from 2 to nops(B) do if B[k] <> B[k-1] then y:= n mod 2^(k-1); if not isprime((y+n-B[k]*2^(k-1))/2) then return false fi fi od; true end proc: select(filter, [6, seq(i,i=7..10^6,4)]); # Robert Israel, Jan 14 2016
-
Mathematica
Select[Range[2^20], AllTrue[Function[w, Map[FromDigits[#, 2] &@ Drop[w, {#}] &, Range@ Length@ w]]@ IntegerDigits[#, 2], PrimeQ] &] (* Michael De Vlieger, Jan 16 2016, Version 10 *)
-
PARI
DroppingAnyDigitGivesAPrime(N,b) = { \\ Property-testing function; returns 1 if true for N, 0 otherwise \\ Works with any base b. Here used with b=2. my(k=b,m); if(N=(k\b), m=(N\k)*(k\b)+(N%(k\b)); if ((m<2)||(!isprime(m)),return(0)); k*=b); return(1); }
-
Python
from sympy import isprime def ok(n): if n < 7 or n%4 != 3: return n == 6 b = bin(n)[2:] return all(isprime(int(b[:i]+b[i+1:], 2)) for i in range(len(b))) print(list(filter(ok, range(2, 2**20)))) # Michael S. Branicky, Jun 07 2021
Extensions
a(24) from Giovanni Resta, Apr 10 2016
a(25)-a(28) from Bert Dobbelaere, Aug 07 2023
Comments