Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
package require Tcl 8.5
|
||||
proc binom {n k} {
|
||||
# Compute the top half of the division; this is n!/(n-k)!
|
||||
set pTop 1
|
||||
for {set i $n} {$i > $n - $k} {incr i -1} {
|
||||
set pTop [expr {$pTop * $i}]
|
||||
}
|
||||
|
||||
# Compute the bottom half of the division; this is k!
|
||||
set pBottom 1
|
||||
for {set i $k} {$i > 1} {incr i -1} {
|
||||
set pBottom [expr {$pBottom * $i}]
|
||||
}
|
||||
|
||||
# Integer arithmetic divide is correct here; the factors always cancel out
|
||||
return [expr {$pTop / $pBottom}]
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
puts "5_C_3 = [binom 5 3]"
|
||||
puts "60_C_30 = [binom 60 30]"
|
||||
Loading…
Add table
Add a link
Reference in a new issue