9 lines
204 B
Text
9 lines
204 B
Text
procedure hailstone(n)
|
|
static cache
|
|
initial {
|
|
cache := table()
|
|
cache[1] := [1]
|
|
}
|
|
/cache[n] := [n] ||| hailstone(if n%2 = 0 then n/2 else 3*n+1)
|
|
return cache[n]
|
|
end
|