This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A053645 #88 Apr 26 2024 03:31:06 %S A053645 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, %T A053645 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, %U A053645 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 %N 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. %C A053645 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 %C A053645 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 %H A053645 Reinhard Zumkeller, <a href="/A053645/b053645.txt">Table of n, a(n) for n = 1..10000</a> %H A053645 J.-P. Allouche and J. Shallit, <a href="http://www.cs.uwaterloo.ca/~shallit/Papers/as0.ps">The ring of k-regular sequences</a>, preprint, Theoretical Computer Sci., 98 (1992), 163-197. %H A053645 J.-P. Allouche and J. Shallit, <a href="http://dx.doi.org/10.1016/0304-3975(92)90001-V">The ring of k-regular sequences</a>, Theoretical Computer Sci., 98 (1992), 163-197 (see Ex. 24). %H A053645 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a> %F A053645 a(n) = n - 2^A000523(n). %F A053645 G.f.: 1/(1-x) * ((2x-1)/(1-x) + Sum_{k>=1} 2^(k-1)*x^2^k). - _Ralf Stephan_, Apr 18 2003 %F A053645 a(n) = (A006257(n)-1)/2. - _N. J. A. Sloane_, May 16 2003 %F A053645 a(1) = 0, a(2n) = 2a(n), a(2n+1) = 2a(n) + 1. - _N. J. A. Sloane_, Sep 13 2003 %F A053645 a(n) = A062050(n) - 1. - _N. J. A. Sloane_, Jun 12 2004 %F A053645 a(A004760(n+1)) = n. - _Reinhard Zumkeller_, May 20 2009 %F A053645 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 %F A053645 Conjecture: a(n) = (1 - A036987(n-1))*(1 + a(n-1)) for n > 1 with a(1) = 0. - _Mikhail Kurkov_, Jul 16 2019 %e A053645 From _Omar E. Pol_, Oct 17 2013: (Start) %e A053645 Written as an irregular triangle the sequence begins: %e A053645 0; %e A053645 0,1; %e A053645 0,1,2,3; %e A053645 0,1,2,3,4,5,6,7; %e A053645 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15; %e A053645 ... %e A053645 (End) %p A053645 seq(n - 2^ilog2(n), n=1..1000); # _Robert Israel_, Dec 23 2015 %t A053645 Table[n - 2^Floor[Log2[n]], {n, 100}] (* _IWABUCHI Yu(u)ki_, May 25 2017 *) %t A053645 Table[FromDigits[Rest[IntegerDigits[n, 2]], 2], {n, 100}] (* _IWABUCHI Yu(u)ki_, May 25 2017 *) %o A053645 (Haskell) %o A053645 a053645 1 = 0 %o A053645 a053645 n = 2 * a053645 n' + b where (n', b) = divMod n 2 %o A053645 -- _Reinhard Zumkeller_, Aug 28 2014 %o A053645 a053645_list = concatMap (0 `enumFromTo`) a000225_list %o A053645 -- _Reinhard Zumkeller_, Feb 04 2013, Mar 23 2012 %o A053645 (PARI) a(n)=n-2^(#binary(n)-1) \\ _Charles R Greathouse IV_, Sep 02 2015 %o A053645 (Magma) [n - 2^Ilog2(n): n in [1..70]]; // _Vincenzo Librandi_, Jul 18 2019 %o A053645 (Python) %o A053645 def a(n): return n - 2**(n.bit_length()-1) %o A053645 print([a(n) for n in range(1, 85)]) # _Michael S. Branicky_, Jul 03 2021 %o A053645 (Python) %o A053645 def A053645(n): return n&(1<<n.bit_length()-1)-1 # _Chai Wah Wu_, Jan 22 2023 %Y A053645 Cf. A000225, A000523, A002262, A004760, A006257, A006516, A030308, A036987, A053644, A062050, A083741, A160588. %K A053645 nonn,base,easy %O A053645 1,6 %A A053645 _Henry Bottomley_, Mar 22 2000