Fibonacci numbers in Tcl
Example for versions
ActiveTcl 8.5,
JTcl 2.1.0,
Tcl 8.4,
Tcl 8.5.7
This example uses iterative definition of Fibonacci numbers.
set fib1 0
set fib2 1
set s ""
for {set i 0} {$i < 16} {incr i} {
set fib3 [expr {$fib1 + $fib2}]
set fib1 $fib2
set fib2 $fib3
append s "$fib1, "
}
puts "$s..."
Comments
]]>blog comments powered by Disqus
]]>