50 lines
1.1 KiB
Plaintext
50 lines
1.1 KiB
Plaintext
fusc = iter () yields (int)
|
|
q: array[int] := array[int]$[1]
|
|
yield(0)
|
|
yield(1)
|
|
|
|
while true do
|
|
x: int := array[int]$reml(q)
|
|
array[int]$addh(q,x)
|
|
yield(x)
|
|
|
|
x := x + array[int]$bottom(q)
|
|
array[int]$addh(q,x)
|
|
yield(x)
|
|
end
|
|
end fusc
|
|
|
|
longest_fusc = iter () yields (int,int)
|
|
sofar: int := 0
|
|
count: int := 0
|
|
|
|
for f: int in fusc() do
|
|
if f >= sofar then
|
|
yield (count,f)
|
|
sofar := 10*sofar
|
|
if sofar=0 then sofar:=10 end
|
|
end
|
|
count := count + 1
|
|
end
|
|
end longest_fusc
|
|
|
|
start_up = proc ()
|
|
po: stream := stream$primary_output()
|
|
|
|
stream$putl(po, "First 61:")
|
|
n: int := 0
|
|
for f: int in fusc() do
|
|
stream$puts(po, int$unparse(f) || " ")
|
|
n := n + 1
|
|
if n = 61 then break end
|
|
end
|
|
|
|
stream$putl(po, "\nLength records:")
|
|
n := 0
|
|
for i, f: int in longest_fusc() do
|
|
stream$putl(po, "fusc(" || int$unparse(i) || ") = " || int$unparse(f))
|
|
n := n + 1
|
|
if n = 5 then break end
|
|
end
|
|
end start_up
|