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.

A082560 a(1)=1, a(n)=2*a(n-1) if n is odd, or a(n)=a(n/2)+1 if n is even.

Original entry on oeis.org

1, 2, 4, 3, 6, 5, 10, 4, 8, 7, 14, 6, 12, 11, 22, 5, 10, 9, 18, 8, 16, 15, 30, 7, 14, 13, 26, 12, 24, 23, 46, 6, 12, 11, 22, 10, 20, 19, 38, 9, 18, 17, 34, 16, 32, 31, 62, 8, 16, 15, 30, 14, 28, 27, 54, 13, 26, 25, 50, 24, 48, 47, 94, 7, 14, 13, 26, 12, 24, 23, 46, 11, 22, 21, 42, 20
Offset: 1

Views

Author

Benoit Cloitre, May 04 2003

Keywords

Comments

b(1)=1, b(n)=2*b(n/2) if n is even, or b(n)=b(n-1)+1 if n is odd produces the sequence of natural numbers.
Seen as a triangle read by rows: T(1,1) = 1; T(n+1,2*k-1) = T(n,k)+1 and T(n+1,2*k) = 2*T(n,k)+2, 1 <= k <= 2^n. - Reinhard Zumkeller, May 13 2015

Examples

			.  1:                                 1
.  2:                 2                                4
.  3:        3               6                5                10
.  4:    4       8       7       14       6       12       11       22
.  5:  5  10   9  18   8  16  15   30   7  14  13   26  12   24  23   46
		

Crossrefs

Cf. A000079 (row lengths), A033484 (right edges), A166060 (row sums), A232642 (duplicates removed).

Programs

  • Haskell
    a082560 n k = a082560_tabf !! (n-1) !! (k-1)
    a082560_row n = a082560_tabf !! (n-1)
    a082560_tabf = iterate (concatMap (\x -> [x + 1, 2 * x + 2])) [1]
    a082560_list = concat a082560_tabf
    -- Reinhard Zumkeller, May 13 2015
  • PARI
    a(n)=if(n<2,1,if(n%2,2*a(n-1),1+a(n/2)))
    

Formula

if n is in A010737 : a(n)=n-1