tests/tcl/common/src/fibo.tcl

#!/usr/local/bin/tclsh
# $Id: fibo.tcl,v 1.2 2003/12/30 01:25:06 davidw Exp $
# http://www.bagley.org/~doug/shootout/

# with help from: Kristoffer Lawson
# Patched for dashot in order to avoid stack overflow (antirez)

# END COMMENT
interp recursionlimit {} 100000

proc fib {n} {
    if {$n < 2} {
	return 1
    } else {
	return [expr {[fib [expr {$n-2}]] + [fib [expr {$n-1}]]}]
    }
}

set N [lindex $argv 0]
if {$N < 1} { set N 1 }
puts [fib $N]

Generated by GNU enscript 1.6.3.