TriOS/forth/fib.mod

22 lines
315 B
Modula-2
Raw Normal View History

2013-12-10 15:32:47 +01:00
: mod:fib ;
\ ( n -- f ) berechnet die nte fibonacci-zahl
: fib
0 1 rot 0 do over + swap loop drop ;
\ benchmark <EFBFBD>ber n fibonacci-zahlen
: fibo-bench
1+ 1 do
i ." fibo(" . ." ) = "
i cnt COG@ swap fib cnt COG@ swap .
swap - ." , ticks : " .
cr
loop ;
decimal 40 fibo-bench hex