An example of a recursive procedure is

proc factorial {number} {
  if {$number <= 1} {
    return 1
  }
  return [expr $number * [factorial [expr $number - 1]]]
}
puts [factorial 5]
puts [factorial 10]

Result:

120
3628800

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading