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 A304030 #22 Feb 22 2022 06:56:07 %S A304030 0,0,1,0,1,4,3,0,5,2,3,2,3,8,3,0,3,10,7,0,1,6,1,0,9,2,3,6,7,4,3,0,13, %T A304030 4,1,4,5,8,9,0,7,2,5,2,3,4,5,0,5,8,5,0,1,14,9,0,7,2,3,6,7,12,9,0,5,6, %U A304030 3,0,1,4,7,0,13,2,1,2,3,8,3,0,7,14,11,0,1,8,3,0,3,2,7,4,5,12,9,0,19,4,1,0 %N A304030 a(n) is the number of steps at which the Collatz ('3x+1') trajectory of n crosses its initial value, or -1 if the number of crossings is infinite. %C A304030 Some treatments of the Collatz conjecture view trajectories as starting to cycle when they reach 1, continuing with 4, 2, 1, 4, 2, 1, ..., while others view trajectories as terminating as soon as 1 is reached; this sequence treats trajectories as terminating at 1. %C A304030 If the Collatz conjecture is true, then for n > 1, a(n) == n (mod 2). %C A304030 If there exists any number n whose Collatz trajectory enters a cycle that includes values above and below n, then the number of crossings would be infinite. If the Collatz conjecture is true, then there exists no such value of n. %C A304030 If a(k) = 0, then a(2^j * k) = 0, for j>0. Therefore the primitives are 1, 20, 24, 52, 56, 68, 72, 84, 88, 100, 116, ..., . - _Robert G. Wilson v_, May 19 2018 %H A304030 Paolo Xausa, <a href="/A304030/b304030.txt">Table of n, a(n) for n = 1..10000</a> %H A304030 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a> %e A304030 The Collatz trajectory of 6 crosses its initial value (6) a total of 4 times, so a(6) = 4: %e A304030 . %e A304030 16 %e A304030 / \ %e A304030 / \ %e A304030 10 / \ %e A304030 / \ / \ %e A304030 / \ / 8 %e A304030 6---------*-----*---*-----------*-------- %e A304030 \ / \ / \ %e A304030 \ / 5 \ %e A304030 \ / \ %e A304030 \ / 4 %e A304030 3 \ %e A304030 ... %e A304030 (Each "*" represents a crossing.) %t A304030 Collatz[n_] := NestWhileList[ If[ OddQ@#, 3# +1, #/2] &, n, # > 1 &]; f[n_] := Block[{x = Length[ SplitBy[ Collatz@ n, # < n +1 &]] - 1}, If[ OddQ@ n && n > 1, x - 1, x]]; Array[f, 100] (* _Robert G. Wilson v_, May 05 2018 *) %o A304030 (Python) %o A304030 def A304030(n): %o A304030 prevc = c = n %o A304030 h = 0 %o A304030 while c > 1: %o A304030 if c % 2: %o A304030 c = 3*c+1 %o A304030 if prevc < n and c > n: h += 1 %o A304030 else: %o A304030 c //= 2 %o A304030 if prevc > n and c < n: h += 1 %o A304030 prevc = c %o A304030 return h %o A304030 print([A304030(n) for n in range(1, 100)]) # _Paolo Xausa_, Feb 22 2022 %Y A304030 Cf. A006370, A070165, A349325. %K A304030 nonn %O A304030 1,6 %A A304030 _Jon E. Schoenfield_, May 04 2018