|
|
A106151
|
|
In binary representation of n: delete one zero in each contiguous block of zeros.
|
|
8
|
|
|
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, 31, 16, 17, 9, 19, 10, 11, 11, 23, 12, 13, 7, 15, 14, 15, 15, 31, 24, 25, 13, 27, 14, 15, 15, 31, 28, 29, 15, 31, 30, 31, 31, 63, 32, 33, 17, 35, 18, 19, 19, 39, 20, 21, 11, 23, 22, 23
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
COMMENTS
|
|
|
LINKS
|
|
|
FORMULA
|
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.
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
|
|
EXAMPLE
|
n=144 = '10010000' -> '101000' = 40 = a(144);
n=145 = '10010001' -> '101001' = 41 = a(145);
n=146 = '10010010' -> '10101' = 21 = a(146).
|
|
PROG
|
(Haskell)
import Data.List (group)
a106151 = foldr (\b v -> 2 * v + b) 0 . concatMap
(\bs'@(b:bs) -> if b == 0 then bs else bs') . group . a030308_row
(PARI) A106151(n) = { my(s=0, i=0); while(n, if(2!=(n%4), s += (n%2)<<i; i++); n >>= 1); (s); }; \\ Antti Karttunen, Jul 01 2024
(Python)
def a(n): return int(bin(n).replace("b", "").replace("10", "1"), 2)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|