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.

A213198 Number of iterations of the map n -> f(f(f(...f(n)...))) to reach the end of the cycle, where f(n) = A006577(n), the initial number n is not counted.

This page as a plain text file.
%I A213198 #22 Oct 27 2019 12:00:49
%S A213198 0,1,5,2,0,7,4,6,7,8,11,8,8,10,10,3,9,6,6,5,5,11,11,9,12,9,13,7,7,7,
%T A213198 10,1,10,9,9,6,6,6,10,7,11,7,8,4,4,4,10,12,10,10,10,12,12,7,7,7,2,7,2,
%U A213198 7,7,15,15,8,14,14,14,11,11,11,14,12,12,12,11,12
%N A213198 Number of iterations of  the map n -> f(f(f(...f(n)...))) to reach the end of the cycle, where f(n) = A006577(n), the initial number n is not counted.
%C A213198 A006577 is the number of halving and tripling steps to reach 1 in '3x+1' problem.
%C A213198 The end of the cycle is 1 or 5 for n = 5, 32, 57, 59, 344, 346, 348, 349, ...
%H A213198 Michel Lagneau, <a href="/A213198/b213198.txt">Table of n, a(n) for n = 1..10000</a>
%e A213198 a(3) = 5 because the 5 iterations to reach 1 are A006577(3) = 7; A006577(7) = 16; A006577(16) = 4; A006577(4) = 2; A006577(2) = 1.
%e A213198 a(5) = 0 because A006577(5) = 5 is the end of the cycle.
%e A213198 a(57) = 2 because A006577(57) = 32 and A006577(32) = 5 is the end of the cycle.
%p A213198 for n from 1 to 200 do:
%p A213198     m:=n: a:=2:
%p A213198     for it from 1 to 1000
%p A213198     while (a>1) do:
%p A213198         jj:=0: a:=0: x:=m:
%p A213198         if m=5 then
%p A213198             printf(`%d, `, it-1): jj:=1:
%p A213198         else
%p A213198             for i from 1 to 1000
%p A213198             while (x>1) do:
%p A213198                 if irem(x, 2)=0 then
%p A213198                     x := x/2: a := a+1:
%p A213198                 else
%p A213198                     x := 3*x+1: a := a+1:
%p A213198                 fi:
%p A213198             od:
%p A213198             m:=a:
%p A213198         fi:
%p A213198     od:
%p A213198     if jj=0 then
%p A213198         printf(`%d, `, it-1):
%p A213198     fi:
%p A213198 od:
%t A213198 Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; f[n_] := Length[Collatz[n]] - 1; Table[k = Rest[NestWhileList[f, n, UnsameQ, All]]; If[k[[1]] == n, 0, k = DeleteCases[k, 0]; If[Length[k] > 1 && k[[-1]] == k[[-2]], k = Most[k]]; Length[k]], {n, 100}] (* _T. D. Noe_, Mar 01 2013 *)
%Y A213198 Cf. A006577.
%K A213198 nonn
%O A213198 1,3
%A A213198 _Michel Lagneau_, Mar 01 2013