Jump to content

Evaluate binomial coefficients: Difference between revisions

Standard ML solution
m (→‎{{header|Wren}}: Minor tidy)
imported>Vukung
(Standard ML solution)
Line 2,769:
<syntaxhighlight lang="smalltalk">binco:arg
^ (self factorial) / (arg factorial * (self-arg) factorial)</syntaxhighlight>
 
=={{header|Standard ML}}==
<syntaxhighlight lang="standardml">
fun binomial n k =
if k > n then 0 else
let fun f (_, 0) = 1
| f (i, d) = f (i + 1, d - 1) * i div d
in f (n - k + 1, k) end
</syntaxhighlight>
 
=={{header|Stata}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.