Binomial( n, k )
Binomial returns the binomial coefficient (n
choosek) of integers n and k,
which is defined as n! / (k! (n-k)!) (see Factorial). We define (0
choose0) = 1, (n choosek) = 0
if k<0 or n<k, and (n choosek) = (-1)^k
(-n+k-1 choosek) if n < 0, which is consistent
with (n choosek) = (n-1 choosek) + (n-1
choosek-1).
(n choosek) is the number of combinations with k elements, i.e., the number of subsets with k elements, of a set with n elements. (n choosek) is the coefficient of the term x^k of the polynomial (x + 1)^n, which is the generating function for (n choose*), hence the name.
gap> List( [0..4], k->Binomial( 4, k ) );
[ 1, 4, 6, 4, 1 ] # Knuth calls this the trademark of Binomial
gap> List( [0..6], n->List( [0..6], k->Binomial( n, k ) ) );;
gap> PrintArray( last );
[ [ 1, 0, 0, 0, 0, 0, 0 ], # the lower triangle is
[ 1, 1, 0, 0, 0, 0, 0 ], # called Pascal\'s triangle
[ 1, 2, 1, 0, 0, 0, 0 ],
[ 1, 3, 3, 1, 0, 0, 0 ],
[ 1, 4, 6, 4, 1, 0, 0 ],
[ 1, 5, 10, 10, 5, 1, 0 ],
[ 1, 6, 15, 20, 15, 6, 1 ] ]
gap> Binomial( 50, 10 );
10272278170
NrCombinations (see Combinations) is the generalization of
Binomial for multisets. Combinations (see
Combinations) computes the set of all combinations of a multiset.