login
Prime numbers in A036991.
2

%I #32 Jan 10 2022 08:32:27

%S 3,5,7,11,13,19,23,29,31,43,47,53,59,61,71,79,83,103,107,109,127,151,

%T 157,167,173,179,181,191,199,211,223,239,251,271,283,307,311,317,331,

%U 347,349,359,367,373,379,383,431,439,443,461,463,467,479,487,491,499

%N Prime numbers in A036991.

%C This sequence includes A000668.

%C Conjecture: The sequence is infinite. For example, in the first million primes (see A000040) 304208 numbers are terms of A036991.

%H Gennady Eremin, <a href="/A350577/b350577.txt">Table of n, a(n) for n = 1..20000</a>

%F Intersection of A000040 and A036991.

%p q:= proc(n) local l, t, i; l:= Bits[Split](n); t:=0;

%p for i to nops(l) do t:= t-1+2*l[i];

%p if t<0 then return false fi

%p od: true

%p end:

%p select(isprime and q, [$2..500])[]; # _Alois P. Heinz_, Jan 07 2022

%t q[n_] := PrimeQ[n] && AllTrue[Accumulate[(-1)^Reverse[IntegerDigits[n, 2]]], # <= 0 &]; Select[Range[500], q] (* _Amiram Eldar_, Jan 07 2022 *)

%o (Python)

%o from sympy import isprime

%o def ok(n):

%o if n == 0: return True

%o count = {"0": 0, "1": 0}

%o for bit in bin(n)[:1:-1]:

%o count[bit] += 1

%o if count["0"] > count["1"]: return False

%o return isprime(n)

%o print([k for k in range(3, 500, 2) if ok(k)]) # _Michael S. Branicky_, Jan 07 2022

%Y Subsequence of A000040, A005408, A036991, A042987, A045395, A095070, A095074, A216285.

%Y Cf. A000668.

%K nonn,base

%O 1,1

%A _Gennady Eremin_, Jan 07 2022