cp's OEIS Frontend

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.

Showing 1-3 of 3 results.

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.

Original entry on oeis.org

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
Offset: 1

Views

Author

Henry Bottomley, Mar 22 2000

Keywords

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

Examples

			From _Omar E. Pol_, Oct 17 2013: (Start)
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)
		

Crossrefs

Programs

  • Haskell
    a053645 1 = 0
    a053645 n = 2 * a053645 n' + b  where (n', b) = divMod n 2
    -- Reinhard Zumkeller, Aug 28 2014
    a053645_list = concatMap (0 `enumFromTo`) a000225_list
    -- Reinhard Zumkeller, Feb 04 2013, Mar 23 2012
    
  • Magma
    [n - 2^Ilog2(n): n in [1..70]]; // Vincenzo Librandi, Jul 18 2019
    
  • Maple
    seq(n - 2^ilog2(n), n=1..1000); # Robert Israel, Dec 23 2015
  • Mathematica
    Table[n - 2^Floor[Log2[n]], {n, 100}] (* IWABUCHI Yu(u)ki, May 25 2017 *)
    Table[FromDigits[Rest[IntegerDigits[n, 2]], 2], {n, 100}] (* IWABUCHI Yu(u)ki, May 25 2017 *)
  • PARI
    a(n)=n-2^(#binary(n)-1) \\ Charles R Greathouse IV, Sep 02 2015
    
  • Python
    def a(n): return n - 2**(n.bit_length()-1)
    print([a(n) for n in range(1, 85)]) # Michael S. Branicky, Jul 03 2021
    
  • Python
    def A053645(n): return n&(1<Chai Wah Wu, Jan 22 2023

Formula

a(n) = n - 2^A000523(n).
G.f.: 1/(1-x) * ((2x-1)/(1-x) + Sum_{k>=1} 2^(k-1)*x^2^k). - Ralf Stephan, Apr 18 2003
a(n) = (A006257(n)-1)/2. - N. J. A. Sloane, May 16 2003
a(1) = 0, a(2n) = 2a(n), a(2n+1) = 2a(n) + 1. - N. J. A. Sloane, Sep 13 2003
a(n) = A062050(n) - 1. - N. J. A. Sloane, Jun 12 2004
a(A004760(n+1)) = n. - Reinhard Zumkeller, May 20 2009
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
Conjecture: a(n) = (1 - A036987(n-1))*(1 + a(n-1)) for n > 1 with a(1) = 0. - Mikhail Kurkov, Jul 16 2019

A298043 If n = Sum_{i=1..h} 2^b_i with b_1 > ... > b_h >= 0, then a(n) = Sum_{i=1..h} i * 2^b_i.

Original entry on oeis.org

0, 1, 2, 4, 4, 6, 8, 11, 8, 10, 12, 15, 16, 19, 22, 26, 16, 18, 20, 23, 24, 27, 30, 34, 32, 35, 38, 42, 44, 48, 52, 57, 32, 34, 36, 39, 40, 43, 46, 50, 48, 51, 54, 58, 60, 64, 68, 73, 64, 67, 70, 74, 76, 80, 84, 89, 88, 92, 96, 101, 104, 109, 114, 120, 64, 66
Offset: 0

Views

Author

Rémy Sigrist, Jan 11 2018

Keywords

Comments

This sequence is similar to A298011.

Examples

			For n = 42:
  42 = 32 + 8 + 2,
  hence a(42) = 1*32 + 2*8 + 3*2 = 54.
		

Crossrefs

Programs

  • PARI
    a(n) = my (b=binary(n), z=0); for (i=1, #b, if (b[i], b[i] = z++)); return (fromdigits(b,2))

Formula

a(n) = Sum_{k = 0..A000120(n)-1} A053645^k(n) for any n > 0 (where A053645^k denotes the k-th iterate of A053645).
a(n) >= n with equality iff n = 0 or n = 2^k for some k >= 0.
a(2 * n) = 2 * a(n).
a(2^n - 1) = A000295(n + 1).
a(2 ^ i + n) = a(n) + 2 ^ i + n for 2 ^ i > n. - David A. Corneth, Jan 14 2018

A175186 a(1)=0. For 1<= n <= 2^m, m>=0, a(n+ 2^m) = a(n)+n.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 4, 7, 1, 3, 4, 7, 6, 9, 11, 15, 1, 3, 4, 7, 6, 9, 11, 15, 10, 13, 15, 19, 19, 23, 26, 31, 1, 3, 4, 7, 6, 9, 11, 15, 10, 13, 15, 19, 19, 23, 26, 31, 18, 21, 23, 27, 27, 31, 34, 39, 35, 39, 42, 47, 48, 53, 57, 63, 1, 3, 4, 7, 6, 9, 11, 15, 10, 13, 15, 19, 19, 23, 26, 31
Offset: 1

Views

Author

Leroy Quet, Mar 01 2010

Keywords

Comments

a(2^m) = 2^m -1.

Crossrefs

Programs

  • Mathematica
    f[l_]:=Join[l,l+Range[Length[l]]]; Nest[f,{0},7] (* Ray Chandler, Mar 04 2010 *)

Extensions

Extended by Ray Chandler, Mar 04 2010
Showing 1-3 of 3 results.