factor/library/test/benchmark/fib.factor

13 lines
225 B
Factor
Raw Normal View History

2004-08-23 23:27:55 -04:00
IN: scratchpad
2004-10-27 21:21:31 -04:00
USE: compiler
2004-08-23 23:27:55 -04:00
USE: math
2004-08-25 20:51:19 -04:00
USE: stack
2004-08-23 23:27:55 -04:00
USE: test
2004-10-27 21:21:31 -04:00
USE: combinators
: fib ( n -- nth fibonacci number )
dup 1 <= [ drop 1 ] [ pred dup fib swap pred fib + ] ifte ;
2004-12-05 23:00:52 -05:00
compiled
2004-08-23 23:27:55 -04:00
[ 9227465 ] [ 34 fib ] unit-test