Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
function choose($n,$k) {
|
||||
if($k -le $n -and 0 -le $k) {
|
||||
$numerator = $denominator = 1
|
||||
0..($k-1) | foreach{
|
||||
$numerator *= ($n-$_)
|
||||
$denominator *= ($_ + 1)
|
||||
}
|
||||
$numerator/$denominator
|
||||
} else {
|
||||
"$k is greater than $n or lower than 0"
|
||||
}
|
||||
}
|
||||
choose 5 3
|
||||
choose 2 1
|
||||
choose 10 10
|
||||
choose 10 2
|
||||
choose 10 8
|
||||
Loading…
Add table
Add a link
Reference in a new issue