summaryrefslogtreecommitdiffstats
path: root/tests/langbench/fib.tcl
blob: a107b7de1a3483a0b7b04e4468e29fd497d29c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
proc fib {n} {
	# Very bogus we have to do {$n - 1} to get performance.
	# But if we don't this takes 35 seconds.  Tcl has issues.
	expr {$n < 2 ? 1 : [fib [expr {$n -2}]] + [fib [expr {$n -1}]]}
}

set i 0
while {$i <= 30} {
	puts "n=$i => [fib $i]"
	incr i
}