login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A106151 In binary representation of n: delete one zero in each contiguous block of zeros. 7

%I #28 Nov 13 2021 02:29:50

%S 1,1,3,2,3,3,7,4,5,3,7,6,7,7,15,8,9,5,11,6,7,7,15,12,13,7,15,14,15,15,

%T 31,16,17,9,19,10,11,11,23,12,13,7,15,14,15,15,31,24,25,13,27,14,15,

%U 15,31,28,29,15,31,30,31,31,63,32,33,17,35,18,19,19,39,20,21,11,23,22,23

%N In binary representation of n: delete one zero in each contiguous block of zeros.

%C Equivalently, change bits 10 -> 0. - _Michael S. Branicky_, Nov 12 2021

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

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(n) <= n; a(n) = n iff n = 2^k-1: a(A000225(n))=A000225(n);

%F A000120(a(n)) = A000120(n);

%F A023416(a(n)) = A023416(n) - A087116(n).

%F a(n) = b(n, 0), where b(n, r) = if n = 1 then 1 else b(floor(n/2), 1 - n mod 2)*(1 + floor((1 + r + n mod 2)/2)) + n mod 2.

%F For n <= 1, a(n) = n, and for n > 1, if n is odd, then a(n) = 1+2*a((n-1)/2), otherwise, when n is even, a(n) = (2^(A007814(n)-1)) * a(A000265(n)). - _Antti Karttunen_, May 13 2018

%e n=144 = '10010000' -> '101000' = 40 = a(144);

%e n=145 = '10010001' -> '101001' = 41 = a(145);

%e n=146 = '10010010' -> '10101' = 21 = a(146).

%o (Haskell)

%o import Data.List (group)

%o a106151 = foldr (\b v -> 2 * v + b) 0 . concatMap

%o (\bs'@(b:bs) -> if b == 0 then bs else bs') . group . a030308_row

%o -- _Reinhard Zumkeller_, Jul 05 2013

%o (PARI) A106151(n) = if(n<=1, n, if(n%2, 1+(2*A106151((n-1)/2)), A106151(n>>valuation(n, 2))<<(valuation(n, 2)-1))); \\ _Antti Karttunen_, May 13 2018

%o (Python)

%o def a(n): return int(bin(n).replace("b", "").replace("10", "1"), 2)

%o print([a(n) for n in range(1, 78)]) # _Michael S. Branicky_, Nov 12 2021

%Y Cf. A007088, A030308, A038573, A090078, A175047, A048679, A348710.

%K nonn,base

%O 1,3

%A _Reinhard Zumkeller_, May 07 2005

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 08:27 EDT 2024. Contains 371769 sequences. (Running on oeis4.)