`` Algorithms
`` www.scriptol.net
``
`` Compute the number of combinations of n items, taken m at a time.
`` Formula C(n,m) = n! / (m! * (n-m)!)
int combinations(int n, int m)
int cnm = 1
int i = 1
int f
if (m * 2) > n let m = n - m
while i <= m
f = n
if (f mod i) = 0
f / i
else
cnm / i
/if
cnm * f
n - 1
let i + 1
return cnm
int main (int argc, array argv)
if argc < 3
print "Usage: comb n m"
else
dyn d = argv[1]
int n = d.toInt()
d = argv[2]
int m = d.toInt()
print
print "The number of combinations of", n, "items", m, "times, is", combinations(n,m)
/if
return 0
main($argc, $argv)