RosettaCodeData/Task/Hailstone-sequence/Mathematica/hailstone-sequence-4.math

3 lines
108 B
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
HailstoneP[n_] := Module[{x = {n}, s = n},
While[s > 1, x = {x, s = If[OddQ@s, 3 s + 1, s/2]}]; Flatten@x]