editing
approved
editing
approved
f[x_] := If[EvenQ[x], x/2, 3x + 1]; g[n_] := FromDigits[Mod[Most[NestWhileList[f, 2n, # > 1 &]], 2, 1] - 1, 2]; Table[g[n], {n, 40}] (* Ray Chandler , Feb 02 2007 *)
approved
editing
proposed
approved
editing
proposed
f[x_] := If[EvenQ[x], x/2, 3x + 1]; g[n_] := FromDigits[Mod[Most[NestWhileList[f, 2n, # > 1 &]], 2, 1] - 1, 2]; Table[g[n], {n, 40}] (* _Ray Chandler_ *)
proposed
editing
editing
proposed
nonn,base
approved
editing
Extended by _Ray Chandler (rayjchandler(AT)sbcglobal.net), _, Feb 02 2007
_N. J. A. Sloane (njas(AT)research.att.com), _, Feb 01 2007
In the "3x+1" problem, let 1 denote a halving step and 0 denote an x->3x+1 step. Then a(n) is obtained by writing the sequence of steps needed to reach 1 from 2n, and reading it as a decimal number.
nonn,new
nonn
N. J. A. Sloane (njas, (AT)research.att.com), Feb 01 2007