NTTL Function - Binomial

Description
Compute n choose k, the binomial coefficient.

The algorithm is based on the formula:

Binomial( n, k ) = n! / ( k! (n-k)! )

We determine whether k or (n - k) is larger, and use the larger value to cancel the numerator. This should lead to a minimum number of multiplications.

Header
<nttl/binomial.h>
Signature
template< class T >
void Binomial( T *Value, size_t n, size_t k )
Parameters
Name Type Description
Value T * Pointer to the result.
size_t n  
size_t k  
Returns
( none )
Example
#include <nttl/binomial.h>
...
long b;
Binomial( &b, 5, 2 );
cout << "(5,2) = " << b << endl;