32 lines
885 B
Text
32 lines
885 B
Text
( 0:?memocells
|
|
& tbl$(memo,!memocells+1) { allocate array }
|
|
& ( Q
|
|
=
|
|
. !arg:(1|2)&1
|
|
| !arg:>2
|
|
& ( !arg:>!memocells:?memocells { Array is too small. }
|
|
& tbl$(memo,!memocells+1) { Let array grow to needed size. }
|
|
| { Array is not too small. }
|
|
)
|
|
& ( !(!arg$memo):>0 { Set index to !arg. Return value at index if > 0 }
|
|
| Q$(!arg+-1*Q$(!arg+-1))+Q$(!arg+-1*Q$(!arg+-2))
|
|
: ?(!arg$?memo) { Set index to !arg. Store value just found. }
|
|
)
|
|
)
|
|
& 0:?i
|
|
& whl
|
|
' (1+!i:~>10:?i&put$(str$(Q$!i " ")))
|
|
& put$\n
|
|
& whl'(1+!i:~>1000:?i&Q$!i)
|
|
& out$(Q$1000)
|
|
& 0:?previous:?lessThan:?i
|
|
& whl
|
|
' ( 1+!i:~>100000:?i
|
|
& Q$!i
|
|
: ( <!previous&1+!lessThan:?lessThan
|
|
| ?
|
|
)
|
|
: ?previous
|
|
)
|
|
& out$!lessThan
|
|
);
|