[CLN-list] efficient calculation of binomial

Bruno Haible bruno at clisp.org
Mon Mar 22 20:39:03 CET 2010


Hi,

Silvestre Abruzzo wrote:
>     binomial(n, n-(i+1))=binomial(n, i)* (n-i)/(i+1)
> 
> I tried to implement the multiplication  by storing the result of of 
> (n-i)/(i+1) in one cl_RA number, but unfortunately the performance are 
> worst than the direct calculation.

It should be faster if you write it as
    (binomial(n, i) * (n-i)) / (i+1)
The multiplication is a multiplication of integers, and the division can be
written as an 'exquo' call.

Bruno


More information about the CLN-list mailing list