Hailstone sequence: Difference between revisions
Content added Content deleted
Line 5,896: | Line 5,896: | ||
=== Nested function call formulation === |
=== Nested function call formulation === |
||
<lang Mathematica>HailstoneF[n_] := NestWhileList[If[OddQ |
<lang Mathematica>HailstoneF[n_] := NestWhileList[If[OddQ[#], 3 # + 1, #/2] &, n, # > 1 &]</lang> |
||
This is probably the most readable and shortest implementation. |
This is probably the most readable and shortest implementation. |