An example of a recursive procedure is
1 | proc factorial {number} { |
2 | if {$number < = 1 } { |
3 | return 1 |
4 | } |
5 | return [expr $number * [factorial [expr $number - 1 ]]] |
6 | } |
7 | puts [factorial 5 ] |
8 | puts [factorial 10 ] |
Result:
1 | 120 |
2 | 3628800 |
Recent Comments