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 A288311 #17 Oct 27 2024 20:29:09 %S A288311 0,1,1,2,0,2,2,3,1,6,3,9,9,3,2,4,12,2,1,7,7,15,15,10,23,10,3,18,18,18, %T A288311 13,5,26,13,13,21,21,21,34,8,27,8,29,16,16,16,10,11,24,24,24,11,11,4, %U A288311 2,19,32,19,32,19,19,45,44,6,27,27,27,14,14,14,31,22 %N A288311 Number of steps, reduced mod n, to reach 1 in the Collatz 3x+1 problem, or -1 if 1 is never reached. %F A288311 a(n) = A006577(n) mod n. %e A288311 For n = 3, which takes 7 steps to reach 1 in the Collatz (3x+1) problem: (10, 5, 16, 8, 4, 2, 1), 7 mod 3 = 1. %t A288311 Table[Mod[-1 + Length[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, # != 1 &]], n], {n, 72}] (* _Michael De Vlieger_, Jun 09 2017 *) %o A288311 (Python) %o A288311 def stepCount(x): %o A288311 x = int(x) %o A288311 steps = 0 %o A288311 while True: %o A288311 if x == 1: %o A288311 break %o A288311 elif x % 2 == 0: %o A288311 x = x/2 %o A288311 steps += 1 %o A288311 else: %o A288311 x = x*3 + 1 %o A288311 steps += 1 %o A288311 return steps %o A288311 n = 1 %o A288311 while True: %o A288311 print(stepCount(n) % n) %o A288311 n += 1 %o A288311 (PARI) a(n)=s=n; c=0; while(s>1, s=if(s%2, 3*s+1, s/2); c++); c % n; \\ _Michel Marcus_, Jun 10 2017 %Y A288311 Cf. A006577. %K A288311 nonn %O A288311 1,4 %A A288311 _Ryan Pythagoras Newton Critchlow_, Jun 07 2017