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.

A384468 a(0) = 1; for n >= 1, a(n) = a(n-1)/2 if a(n-1) is even, otherwise a(n) = 2*a(n-1) + n.

Original entry on oeis.org

1, 3, 8, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 19, 52, 26, 13, 43, 104, 52, 26, 13, 48, 24, 12, 6, 3, 33, 94, 47, 124, 62, 31, 95, 224, 112, 56, 28, 14, 7, 54, 27, 96, 48, 24, 12, 6, 3, 54, 27, 104, 52, 26, 13, 80, 40, 20, 10, 5, 69, 198, 99, 260, 130, 65, 195, 456, 228, 114, 57, 184
Offset: 0

Views

Author

Simon R Blow, May 30 2025

Keywords

Comments

The sequence behaves similarly to the Collatz sequence but introduces a linearly increasing term n when updating odd values.
a(n) = 1 for n = 0, 5, 9, 60843, 19628571, and 772944372 and no other values up to 10^14. - David Radcliffe, Jun 18 2025

Examples

			a(2) = 2*3 + 2 = 8 (since a(1) is odd).
a(3) = 8/2 = 4 (since a(2) is even).
		

Crossrefs

Programs

  • Mathematica
    a[0] = 1; a[n_] := a[n] = If[EvenQ[a[n-1]], a[n-1]/2, 2*a[n-1] + n]; Array[a, 100, 0] (* Amiram Eldar, May 30 2025 *)
  • Python
    def generate_sequence(n_terms):
        seq = [1]  # a(0) = 1
        for n in range(1, n_terms):
            prev = seq[-1]
            if prev % 2 == 0:
                seq.append(prev // 2)
            else:
                seq.append(2 * prev + n)
        return seq
    seq = generate_sequence(1000)
    print(seq)

Formula

a(0) = 1.
For n >= 1:
a(n) = a(n-1)/2 if a(n-1) is even;
a(n) = 2*a(n-1) + n if a(n-1) is odd.