# T is the 3x+1 function discussed in equation (2.1) restart: n := 2^50 -1; # Change n print(`n = `.``(2)^50-1 = n); T := proc(n:posint) if type(n,odd) then (3*n+1)/2 else n/2 fi end: sigma := proc(n:posint) # Computes stopping time local m,k; if n = 1 then k := infinity else k := 0; m := n; while m >= n do k := k+1; m := T(m); od; fi; k; end: print(``(sigma)(n) = sigma(n)); sigma_infinity := proc(n:posint) # Computes total stopping time local m,k; k := 1; m := n; while T(m) <> 1 do k := k+1; m := T(m); od; k; end: print(``(sigma[infinity])(n) = sigma_infinity(n)); print(` It is conjectured that the limit of sigma_infinity(k)/log(k) exists. See for yourself in the above loglogplot.`); l := []: for k from 2 to 200 do l := [ op(l) , [k,sigma_infinity(k)/log(k)] ]: od: plots[loglogplot](l, x=2..200,style=POINT,symbol=CIRCLE,scaling=CONSTRAINED);