OFFSET
1,2
COMMENTS
A variation of the "3x+1" problem. - T. D. Noe, Feb 06 2012
LINKS
Michel Lagneau, Table of n, a(n) for n = 1..10000
EXAMPLE
a(8) = 7 because the trajectory of 8 is 8 -> 11 -> 15 -> 5 -> 7-> 9 -> 3-> 1 with 7 iterations.
MAPLE
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:
MATHEMATICA
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 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Feb 04 2012
STATUS
approved