RosettaCodeData/Task/Hailstone-sequence/APL/hailstone-sequence-1.apl

10 lines
327 B
APL
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
seqhailstone n;next
⍝ Returns the hailstone sequence for a given number
seqn ⍝ Init the sequence
:While n1
next(n÷2) (1+3×n) ⍝ Compute both possibilities
nnext[1+2|n] ⍝ Pick the appropriate next step
seq,n ⍝ Append that to the sequence
:EndWhile