Evaluate binomial coefficients: Difference between revisions
Content added Content deleted
m (→{{header|Tcl}}: Add comments) |
m (→{{header|Tcl}}: whitespace) |
||
Line 38: | Line 38: | ||
set pTop [expr {$pTop * $i}] |
set pTop [expr {$pTop * $i}] |
||
} |
} |
||
# Compute the bottom half of the division |
# Compute the bottom half of the division |
||
set pBottom 1 |
set pBottom 1 |
||
Line 43: | Line 44: | ||
set pBottom [expr {$pBottom * $i}] |
set pBottom [expr {$pBottom * $i}] |
||
} |
} |
||
# Integer arithmetic divide is correct here; the factors always cancel out |
# Integer arithmetic divide is correct here; the factors always cancel out |
||
return [expr {$pTop / $pBottom}] |
return [expr {$pTop / $pBottom}] |