12 lines
374 B
Text
12 lines
374 B
Text
F hailstone(=n)
|
||
V seq = [n]
|
||
L n > 1
|
||
n = I n % 2 != 0 {3 * n + 1} E n I/ 2
|
||
seq.append(n)
|
||
R seq
|
||
|
||
V h = hailstone(27)
|
||
assert(h.len == 112 & h[0.<4] == [27, 82, 41, 124] & h[(len)-4 ..] == [8, 4, 2, 1])
|
||
|
||
V m = max((1..99999).map(i -> (hailstone(i).len, i)))
|
||
print(‘Maximum length #. was found for hailstone(#.) for numbers <100,000’.format(m[0], m[1]))
|