Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Different factorial implementations
# factorial, recursive proc fact1 n {expr {$n<2?1:$n*[fact1 [incr n -1]]}} # factorial, loop proc fact2 n {for {set f 1} {1<$n} {incr n -1} {set f [expr {$f*$n}]}; set f} # factorial, custom multiplication implementation proc mul {a b} {expr {($b&1?$a:0)+($b?[mul [expr {$a<<1}] [expr {$b>>1}]]:0)}} proc fact3 n {for {set f 1} {1<$n} {incr n -1} {set f [mul $f $n]}; set f} # test output for {set i 1} {$i<10} {incr i} { puts $i:\t[fact1 $i]\t[fact2 $i]\t[fact3 $i]}
run
|
edit
|
history
|
help
0
Perfect neg float bin multiplier
3
binds
Perfect binary mul and even odd assign 2
Dec to binary addition
eerewr
Perfect bin mul eo float
code to identify whether particular coordinate lies in bbox
XorShift On Tcl
dssd