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.

A363270 The result, starting from n, of Collatz steps x -> (3x+1)/2 while odd, followed by x -> x/2 while even.

Original entry on oeis.org

1, 1, 1, 1, 1, 3, 13, 1, 7, 5, 13, 3, 5, 7, 5, 1, 13, 9, 11, 5, 1, 11, 5, 3, 19, 13, 31, 7, 11, 15, 121, 1, 25, 17, 5, 9, 7, 19, 67, 5, 31, 21, 49, 11, 17, 23, 121, 3, 37, 25, 29, 13, 5, 27, 47, 7, 43, 29, 67, 15, 23, 31, 91, 1, 49, 33, 19, 17, 13, 35, 121, 9, 55
Offset: 1

Views

Author

Dustin Theriault, May 23 2023

Keywords

Comments

Each x -> (3x+1)/2 step decreases the number of trailing 1-bits by 1 so A007814(n+1) of them, and the result of those steps is 2*A085062(n).

Crossrefs

Cf. A160541 (number of iterations).
Cf. A075677.

Programs

  • C
    int a(int n) {
      while (n & 1) n += (n >> 1) + 1;
      while (!(n & 1)) n >>= 1;
      return n;
    }
    
  • Mathematica
    OddPart[x_] := x / 2^IntegerExponent[x, 2]
    Table[OddPart[(3/2)^IntegerExponent[i + 1, 2] * (i + 1) - 1], {i, 100}]
  • PARI
    oddpart(n) = n >> valuation(n, 2); \\ A000265
    a(n) = oddpart((3/2)^valuation(n+1, 2)*(n+1) - 1); \\ Michel Marcus, May 24 2023

Formula

a(n) = OddPart((3/2)^A007814(n+1)*(n+1) - 1), where OddPart(t) = A000265(t).
a(n) = OddPart(A085062(n)).