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.
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
Keywords
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.
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
- Ya-Ping Lu, A plot of a(n) for n in the range of (-10000, 10000)
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
Comments