Help:=proc(): print( ` C(x), LP(x) , SeqLP(N) , Cf(x), SeqLPf(N) `): end: #C(x): The Collatz function C:=proc(x) if x mod 2=0 then x/2: else 3*x+1: fi: end: #LP(x): the smallest number of applications of C #to get to 1 LP:=proc(x) local i,y: y:=x: for i from 0 while y<>1 do y:=C(y): od: i: end: #SeqLP(N): the first N terms of LP(x) SeqLP:=proc(N) local x: [ seq(LP(x),x=1..N) ]: end: ####fast version of C #Cf(x): The Collatz function, fast version Cf:=proc(x) if x mod 2=0 then x/2: else (3*x+1)/2: fi: end: #LPf(x): the smallest number of applications of C #to get to 1,using Cf LPf:=proc(x) local i,y: y:=x: for i from 0 while y<>1 do y:=Cf(y): od: i: end: #SeqLPf(N): the first N terms of LPf(x) SeqLPf:=proc(N) local x: [ seq(LPf(x),x=1..N) ]: end: ####Even faster version of C #Cf(x): The Collatz function, fast version Cf:=proc(x) if x mod 2=0 then x/2: else (3*x+1)/2: fi: end: #LPf(x): the smallest number of applications of C #to get to 1,using Cf LPf:=proc(x) local i,y: y:=x: for i from 0 while y<>1 do y:=Cf(y): od: i: end: #SeqLPf(N): the first N terms of LP(x) SeqLPf:=proc(N) local x: [ seq(LPf(x),x=1..N) ]: end: