[gforth] / gforth / fib.fs  

gforth: gforth/fib.fs

File: [gforth] / gforth / fib.fs (download)
Revision: 1.2, Wed Jan 18 12:56:12 2006 UTC (7 years, 4 months ago) by anton
Branch: MAIN
CVS Tags: v0-7-0, HEAD
Changes since 1.1: +4 -0 lines
documented S>NUMBER? S>UNUMBER?
minor changes

\ Note: This is incorrect ("n fib" produces the result for fib(n+1)),
\ but we do not change it to ensure that future timing results are
\ comparable to older timing results.

: fib ( n1 -- n2 )
    dup 2 < if
	drop 1
    else
	dup
	1- recurse
	swap 2 - recurse
	+
    then ;

: main 34 fib drop ;

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help