login
Numbers whose binary expansion does not begin 111.
1

%I #28 Feb 17 2021 01:57:40

%S 0,1,2,3,4,5,6,8,9,10,11,12,13,16,17,18,19,20,21,22,23,24,25,26,27,32,

%T 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,

%U 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83

%N Numbers whose binary expansion does not begin 111.

%H Reinhard Zumkeller, <a href="/A004765/b004765.txt">Table of n, a(n) for n = 1..10000</a>

%F a(1) = 0, a(2) = 1, a(3) = 2, a(4) = 3, a(2^(m+1)+2^m+k+2) = 2^(m+2) + k, m >= 0, 0 <= k < (2^(m+1)+2^m). - _Yosu Yurramendi_, Aug 08 2016

%F From _Robert Israel_, Aug 08 2016: (Start)

%F For n >= 5, a(2n-2) = 2 a(n) and a(2n-1) = 2 a(n)+1.

%F G.f. g(x) satisfies g(x) - (2/x + 2/x^2)*g(x^2) = -x^2 - x^4 - x^6 + x^9/(1-x^2). (End)

%p f:= proc(n) option remember;

%p if n < 8 then n-1

%p else 2*procname(floor((n+2)/2))+(n mod 2)

%p fi

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Aug 08 2016

%t w = {1, 1, 1}; Select[Range[0, 83], If[# < 2^(Length@ w - 1), True, Take[IntegerDigits[#, 2], Length@ w] != w] &] (* _Michael De Vlieger_, Aug 08 2016 *)

%o (Haskell)

%o a004765 n = a004765_list !! n

%o a004765_list = filter f [0..] where

%o f x | x <= 8 = x /= 7

%o | otherwise = f (x `div` 2)

%o -- _Reinhard Zumkeller_, Jun 03 2012

%Y Cf. A007088.

%K nonn,easy,base

%O 1,3

%A _N. J. A. Sloane_