I [found](http://bit.ly/ar7uDi) a couple of naive fibonacci programs
by Bill Spight that work:

: FIB ?DUP
  CASE
    0 of 1 endof
    1 of 1- RECURSE 1 endof
    1- RECURSE TUCK +
  ENDCASE ;

: FIB DUP 0= IF 1 ELSE 1- RECURSE TUCK + THEN ;

But I would like to know why mine does not work:


: fib { n -- fibn }
  assert( n 0>= )
  n CASE
    0 OF 0 ENDOF
    1 OF 1 ENDOF
    2 OF 1 ENDOF        
    ( otherwise ) n 1 - recurse n 2 - recurse +
  ENDCASE ;


Reply via email to