|
|
A053645
|
|
Distance to largest power of 2 less than or equal to n; write n in binary, change the first digit to zero, and convert back to decimal.
|
|
76
|
|
|
0, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,6
|
|
COMMENTS
|
Triangle read by rows in which row n lists the first 2^n nonnegative integers (A001477), n >= 0. Right border gives A000225. Row sums give A006516. See example. - Omar E. Pol, Oct 17 2013
Without the initial zero also: zeroless numbers in base 3 (A032924: 1, 2, 11, 12, 21, ...), ternary digits decreased by 1 and read as binary. - M. F. Hasler, Jun 22 2020
|
|
LINKS
|
|
|
FORMULA
|
G.f.: 1/(1-x) * ((2x-1)/(1-x) + Sum_{k>=1} 2^(k-1)*x^2^k). - Ralf Stephan, Apr 18 2003
a(1) = 0, a(2n) = 2a(n), a(2n+1) = 2a(n) + 1. - N. J. A. Sloane, Sep 13 2003
a(n) = f(n-1,1) with f(n,m) = if n < m then n else f(n-m,2*m). - Reinhard Zumkeller, May 20 2009
|
|
EXAMPLE
|
Written as an irregular triangle the sequence begins:
0;
0,1;
0,1,2,3;
0,1,2,3,4,5,6,7;
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;
...
(End)
|
|
MAPLE
|
|
|
MATHEMATICA
|
Table[FromDigits[Rest[IntegerDigits[n, 2]], 2], {n, 100}] (* IWABUCHI Yu(u)ki, May 25 2017 *)
|
|
PROG
|
(Haskell)
a053645 1 = 0
a053645 n = 2 * a053645 n' + b where (n', b) = divMod n 2
a053645_list = concatMap (0 `enumFromTo`) a000225_list
(Python)
def a(n): return n - 2**(n.bit_length()-1)
(Python)
|
|
CROSSREFS
|
Cf. A000225, A000523, A002262, A004760, A006257, A006516, A030308, A036987, A053644, A062050, A083741, A160588.
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|