Skip to content

Commit 2e16605

Browse files
Create factorial non-recursive.tcl
1 parent 9ea8091 commit 2e16605

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

factorial non-recursive.tcl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Written by: Udaya Shankar S
2+
Dated: 15.11.2022
3+
Version: 1.0
4+
5+
proc factorial {a} {
6+
set s 1
7+
for {set i $a } {$i > 0} {incr i -1} {
8+
set s [expr $s*$i]
9+
}
10+
return $s
11+
}
12+
13+
puts [factorial 10] ; # factorial of 10

0 commit comments

Comments
 (0)