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.
%I A383131 #19 Aug 13 2025 19:33:40 %S A383131 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, %T A383131 10,10,10,23,7,49,49,62,13,13,13,13,13,26,26,39,52,52,52,65,16,16,16, %U A383131 78,16,16,16,29,16,42,42,55,55,55,55,68,6,19,19,19,19,19 %N 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. %C A383131 A plot of a(n) for non-zero integers n in the range of (-10000, 10000) is given in LINKS. %C A383131 Conjecture: a(n) != -1 for any positive or negative integer n. %H A383131 Rémy Sigrist, <a href="/A383131/b383131.txt">Table of n, a(n) for n = 1..10000</a> %H A383131 Ya-Ping Lu, <a href="/A383131/a383131.pdf">A plot of a(n) for n in the range of (-10000, 10000)</a> %e A383131 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. %p A383131 a:= proc(n) option remember; `if`(n=1, 0, %p A383131 1+a(`if`(n::even, -n/2, 3*n+1))) %p A383131 end: %p A383131 seq(a(n), n=1..69); # _Alois P. Heinz_, Aug 13 2025 %t A383131 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 *) %o A383131 (Python) %o A383131 def A383131(n): %o A383131 ct = 0 %o A383131 while n != 1: n = 3*n+1 if n%2 else -n>>1; ct += 1 %o A383131 return ct %o A383131 (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 %Y A383131 Cf. A006577, A381055. %K A383131 nonn %O A383131 1,2 %A A383131 _Ya-Ping Lu_, Apr 17 2025