retroforth/example/RecursiveFibonacci.forth

18 lines
259 B
Text
Raw Normal View History

# example|RecursiveFibonacci
Declare module constant (prevents reloading when using `import`):
````
:example|RecursiveFibonacci ;
````
----
````
:fib (n-m)
dup
[ n:zero? ] [ #1 eq? ] bi or
not 0; drop
[ n:dec fib ] sip
[ #2 - fib ] call + ;
````