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-2 of 2 results.

A383131 a(n) is the number of iterations that n requires to reach 1 under the map x -> -x/2 if x is even, 3x + 1 if x is odd; a(n) = -1 if 1 is never reached.

Original entry on oeis.org

0, 3, 12, 2, 5, 5, 8, 5, 11, 11, 50, 14, 14, 14, 53, 4, 17, 17, 43, 7, 7, 7, 20, 7, 46, 46, 59, 10, 10, 10, 23, 7, 49, 49, 62, 13, 13, 13, 13, 13, 26, 26, 39, 52, 52, 52, 65, 16, 16, 16, 78, 16, 16, 16, 29, 16, 42, 42, 55, 55, 55, 55, 68, 6, 19, 19, 19, 19, 19
Offset: 1

Views

Author

Ya-Ping Lu, Apr 17 2025

Keywords

Comments

A plot of a(n) for non-zero integers n in the range of (-10000, 10000) is given in LINKS.
Conjecture: a(n) != -1 for any positive or negative integer n.

Examples

			a(3) = 12 because it takes 12 steps for n = 3 to reach 1: 3 -> 10 -> -5 -> -14 -> 7 -> 22 -> -11 -> -32 -> 16 -> -8 -> 4 -> -2 -> 1.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=1, 0,
          1+a(`if`(n::even, -n/2, 3*n+1)))
        end:
    seq(a(n), n=1..69);  # Alois P. Heinz, Aug 13 2025
  • Mathematica
    js[n_] := If[EvenQ[n],-n/2,3n+1]; f[n_] := Length[ NestWhileList[js, n, # != 1 &]] - 1; Table[ f[n], {n, 69}] (* James C. McMahon, Apr 30 2025 *)
  • PARI
    a(n) = { for (k = 0, oo, if (n==1, return (k), n = if (n%2, 3*n+1, -n/2));); } \\ Rémy Sigrist, Apr 19 2025
  • Python
    def A383131(n):
        ct = 0
        while n != 1: n = 3*n+1 if n%2 else -n>>1; ct += 1
        return ct
    

A386885 a(n) is the number of iterations that -n requires to reach 1 under the map x -> -x/2 if x is even, 3x + 1 if x is odd.

Original entry on oeis.org

2, 1, 4, 4, 10, 13, 13, 3, 16, 6, 6, 6, 45, 9, 9, 6, 48, 12, 12, 12, 25, 51, 51, 15, 15, 15, 15, 15, 41, 54, 54, 5, 18, 18, 18, 18, 31, 44, 44, 8, 57, 8, 8, 8, 21, 21, 21, 8, 34, 47, 47, 47, 60, 60, 60, 11, 11, 11, 11, 11, 86, 24, 24, 8, 37, 50, 50, 50, 50, 63
Offset: 1

Views

Author

Ryosuke Miyazawa, Aug 06 2025

Keywords

Comments

Equivalently, a(n) is the number of iterations that n requires to reach -1 under the map x -> -x/2 if x is even, 3x - 1 if x is odd. This is called the shadow Collatz map in the Ryosuke Miyazawa reference.
Conjecture: Every nonzero integer reaches 1. Verified numerically up to +-5*10^7.

Examples

			n = 7 requires a(7) = 13 steps to reach -1: 7 -> 20 -> -10 -> 5 -> 14 -> -7 -> -22 -> 11 -> 32 -> -16 -> 8 -> -4 -> 2 -> -1.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; `if`(n=-1, 0,
          1+a(`if`(n::even, -n/2, 3*n-1)))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Aug 13 2025
  • Mathematica
    a[n_]:=Module[{s = 0, m = n},While[m!=-1,s++;m=If[BitAnd[m,1]==1,3*m -1,-m/2]];s];Array[a,70] (* James C. McMahon, Aug 18 2025 *)
  • PARI
    a(n) = if(n==0, oo, my(s=0); while(n!=-1, s++; n=if(bitand(n,1), 3*n-1, -n/2)); s) \\ Andrew Howroyd, Aug 06 2025

Formula

a(1) = 2; for n > 1, a(n) = 1 + a(f(n)), where f(n) = -n/2 if n is even, 3n - 1 if n is odd.
Showing 1-2 of 2 results.