%I #17 Oct 02 2018 13:00:38
%S 4,8,9,12,17,18,19,20,24,25,28,32,34,35,36,37,38,39,40,41,44,49,50,51,
%T 52,56,57,60,65,68,69,70,71,72,73,74,75,76,77,78,79,81,82,83,84,88,89,
%U 92,96,98,99,100,101,102,103,104,105,108,113,114,115,116,120
%N Integers whose binary representation contains a consecutive string of zeros of prime length.
%H Chai Wah Wu, <a href="/A319302/b319302.txt">Table of n, a(n) for n = 1..10000</a>
%e 81 = (1010001)_2 is a term because it contains a run of zeros of length 3, and 3 is a prime. 16 = (10000)_2 is not a term because it contains only a run of 4 zeros and 4 is not a prime.
%t Select[Range[120], AnyTrue[ Differences@ Flatten@ Position[ IntegerDigits[ 2*# + 1, 2], 1] - 1, PrimeQ] &] (* _Giovanni Resta_, Sep 17 2018 *)
%o (PARI) is(n) = my(b=binary(n), i=0); for(k=1, #b, if(b[k]==0, i++); if(b[k]==1 || k==#b, if(ispseudoprime(i), return(1), i=0))); 0 \\ _Felix Fröhlich_, Sep 17 2018
%o (Python)
%o from re import split
%o from sympy import isprime
%o A319302_list, n = [], 1
%o while len(A319302_list) < 10000:
%o for d in split('1+',bin(n)[2:]):
%o if isprime(len(d)):
%o A319302_list.append(n)
%o break
%o n += 1 # _Chai Wah Wu_, Oct 02 2018
%Y Cf. A004753, A318940.
%K nonn,base,easy
%O 1,1
%A _W. Zane Billings_, Sep 16 2018
%E More terms from _Giovanni Resta_, Sep 17 2018
|