Combinations and permutations: Difference between revisions
+Stata
m (new builtins) |
(+Stata) |
||
Line 1,867:
C(1000, 333) = 5.77613455E+274
</pre>
=={{header|Stata}}==
The '''[https://www.stata.com/help.cgi?mf_comb comb]''' function is builtin. Here is an implementation, together with perm:
<lang stata>real scalar comb1(n, k) {
return(exp(lnfactorial(n)-lnfactorial(k)-lnfactorial(n-k)))
}
real scalar perm(n, k) {
return(exp(lnfactorial(n)-lnfactorial(n-k)))
}</lang>
=={{header|Tcl}}==
Line 1,971 ⟶ 1,982:
</pre>
It should be noted that for large values, it can be ''much'' faster to use the floating point version (at a cost of losing significance). In particular <code>expr C(1000,500)</code> takes approximately 1000 times longer to compute than <code>expr fC(1000,500)</code>
=={{header|VBScript}}==
|