login
Number of steps to reach the number 1 of the map n -> n/3 if x==0 (mod 3), n -> (4n-1)/3 if x==1 (mod 3), n -> (4n+1)/3 if x==2 (mod 3).
1

%I #15 Mar 13 2023 07:19:52

%S 0,2,1,5,4,3,3,7,2,21,6,6,20,10,5,5,19,4,9,4,4,23,18,8,8,8,3,27,22,22,

%T 17,12,7,7,7,7,26,21,21,16,16,11,11,11,6,6,6,6,25,20,20,20,15,5,15,10,

%U 10,10,10,5,5,29,5,24,24,24,19,19,19,19,14,9,14,9

%N Number of steps to reach the number 1 of the map n -> n/3 if x==0 (mod 3), n -> (4n-1)/3 if x==1 (mod 3), n -> (4n+1)/3 if x==2 (mod 3).

%C A variation of the "3x+1" problem. - _T. D. Noe_, Feb 06 2012

%H Michel Lagneau, <a href="/A185023/b185023.txt">Table of n, a(n) for n = 1..10000</a>

%e a(8) = 7 because the trajectory of 8 is 8 -> 11 -> 15 -> 5 -> 7-> 9 -> 3-> 1 with 7 iterations.

%p T:=array(0..2):for n from 1 to 100 do:ii:=0:n0:=n: i:=0:for it from 1 to 100 while(ii=0) do:T[0]:=n0/3: T[1]:=(4*n0-1)/3: T[2]:=(4*n0+1)/3:r:=irem(n0,3):n0:=T[r]: i:=i+1:if n0=1 then ii:=1: else fi:od: printf(`%d, `,i):od:

%t nxt[n_]:=Module[{m=Mod[n,3]},Which[m==0,n/3,m==1,(4n-1)/3,m==2,(4n+1)/3]]; Table[Length[NestWhileList[nxt,n,#!=1&]]-1,{n,80}] (* _Harvey P. Dale_, Jul 20 2013 *)

%Y Cf. A006577 (3x+1 problem).

%K nonn

%O 1,2

%A _Michel Lagneau_, Feb 04 2012