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.

A160541 Number of odd-then-even runs to reach 1 from n under the modified "3x+1" map: x -> x/2 if x is even, x -> (3x+1)/2 if x is odd.

Original entry on oeis.org

0, 1, 1, 1, 1, 2, 3, 1, 4, 2, 3, 2, 2, 4, 2, 1, 3, 5, 4, 2, 1, 4, 2, 2, 5, 3, 17, 4, 4, 3, 16, 1, 6, 4, 2, 5, 4, 5, 6, 2, 17, 2, 6, 4, 4, 3, 16, 2, 5, 6, 5, 3, 2, 18, 17, 4, 7, 5, 6, 3, 3, 17, 15, 1, 6, 7, 5, 4, 3, 3, 16, 5, 18, 5, 2, 5, 5, 7, 6, 2, 4, 18, 17
Offset: 1

Views

Author

Brenton Bostick (bostick(AT)gmail.com), May 18 2009

Keywords

Comments

The 2->1 step is not counted.
From Dustin Theriault, May 24 2023: (Start)
The ratio of the partial sum of a(n) to the partial sum of A006577(n) appears to approach 1/6 (observation for n = 1..10^10).
The ratio of the partial sum of a(n) to the partial sum of A286380(n) appears to approach 1/2 (observation for n = 1..10^10). (End)
Number of steps x -> A363270(x) to go from n to 1. - Dustin Theriault, Jul 09 2023

Examples

			7->11->17->26->13->20->10->5->8->4->2->1, so the odd-then-even runs are (7->11->17->26) (13->20->10) (5->8->4->2), and a(7) is 3.
		

Crossrefs

Programs

  • C
    int a(int n) {
      int steps = 0;
      while (n > 1) {
        while (n & 1) n += (n >> 1) + 1;
        while (!(n & 1)) n >>= 1;
        ++steps;
      }
      return steps;
    } /* Dustin Theriault, May 23 2023 */
  • Mathematica
    Array[Length@ Split[Most@ NestWhileList[If[EvenQ@ #, #/2, (3 # + 1)/2] &, #, # > 1 &], Or[OddQ[#1], EvenQ[#2]] &] &, 120] (* Corrected by Michael De Vlieger, Jul 19 2021 *)

Formula

From Alan Michael Gómez Calderón, Mar 19 2025: (Start)
a(n) = A346965(A000265(n)) - (n mod 2) + 1;
a(n) = a(A363270(n)) + 1 for n >= 2. (End)

A213181 Number of chains of even numbers of length 2 or more in the Collatz (3x+1) trajectory of n.

Original entry on oeis.org

0, 0, 1, 1, 1, 1, 3, 1, 4, 1, 3, 2, 2, 3, 2, 1, 3, 4, 4, 2, 1, 3, 2, 2, 5, 2, 17, 4, 4, 2, 16, 1, 6, 3, 2, 5, 4, 4, 6, 2, 17, 1, 6, 4, 4, 2, 16, 2, 5, 5, 5, 3, 2, 17, 17, 4, 7, 4, 6, 3, 3, 16, 15, 1, 6, 6, 5, 4, 3, 2, 16, 5, 18, 4, 2, 5, 5, 6, 6, 2, 4, 17, 17
Offset: 1

Views

Author

Jayanta Basu, Feb 28 2013

Keywords

Comments

A pair of even numbers that appear side by side in Collatz trajectory of n is considered a chain of length 2 and likewise for chains of greater length.

Examples

			For n=3, Collatz trajectory of 3 is 3,10,5,16,8,4,2,1, hence the only chain is 16,8,4,2 and so a(3)=1.
For n=12: 12,6,3,10,5,16,8,4,2,1 and as such there are two chains 12,6 and 16,8,4,2 so a(12)=2.
		

Crossrefs

Programs

  • Mathematica
    Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; Table[c = Collatz[n]; cnt = 0; evenCnt = 0; Do[If[OddQ[i], evenCnt = 0, evenCnt++; If[evenCnt == 2, cnt++]], {i, c}]; cnt, {n, 100}] (* T. D. Noe, Feb 28 2013 *)

Formula

a(n) = a(A363270(A014682(n))) + 1 for n >= 3. - Alan Michael Gómez Calderón, Apr 09 2025
a(n) = a(A139391(n)) + A133872(n) for n >= 2. - Alan Michael Gómez Calderón, Apr 23 2025

A375782 The 2-adic valuation of the result, starting from n, of Collatz steps x -> (3x+1)/2 while odd.

Original entry on oeis.org

1, 1, 3, 2, 3, 1, 1, 3, 1, 1, 1, 2, 2, 1, 4, 4, 1, 1, 2, 2, 5, 1, 4, 3, 1, 1, 1, 2, 2, 1, 1, 5, 1, 1, 4, 2, 3, 1, 1, 3, 1, 1, 1, 2, 2, 1, 1, 4, 1, 1, 2, 2, 4, 1, 2, 3, 1, 1, 1, 2, 2, 1, 3, 6, 1, 1, 3, 2, 3, 1, 1, 3, 1, 1, 1, 2, 2, 1, 2, 4, 1, 1, 2, 2, 7, 1, 3
Offset: 1

Views

Author

Ruud H.G. van Tol, Aug 28 2024

Keywords

Comments

The number of steps is A007814(n+1) and their result is 2*A085062(n).
a(n) = 1 iff A085062(n) is odd, which is when n+1 is in A338691.

Examples

			7 -> 11 -> 17 -> 26, so a(7) = A007814(26) = 1.
		

Crossrefs

Programs

  • PARI
    a(n)= valuation((3/2)^valuation(n+1, 2)*(n+1)-1, 2);

Formula

For n == 0 (mod 2), a(n) = A007814(n).
For k > 0, a(2^k-1) = A007814(3^k-1).
a(n) = 1 + A007814(A085062(n)).
Showing 1-3 of 3 results.