RosettaCodeData/Task/Hailstone-sequence/Arturo/hailstone-sequence.arturo
2026-02-01 16:33:20 -08:00

26 lines
436 B
Text

hailstone: function [n][
ret: @[n]
while [n>1][
switch 1 = and n 1 -> n: 1+3*n
-> n: n/2
append 'ret n
]
ret
]
print "Hailstone sequence for 27:"
print hailstone 27
maxHailstoneLength: 0
maxHailstone: 0
loop 2..1000 'x [
l: size hailstone x
if l>maxHailstoneLength [
maxHailstoneLength: l
maxHailstone: x
]
]
print ["max hailstone sequence found (<100000): of length" maxHailstoneLength "for" maxHailstone]