Python and Combinatorics

Alan Isaac aisaac at
Thu Oct 25 23:14:11 CEST 2007

none wrote:
> 	Is there some package to calculate combinatorical stuff like (n over 
> k), i.e., n!/(k!(n - k!) ?

Yes, in SciPy.
Alan Isaac

>>> from scipy.misc.common import comb
>>> help(comb)
Help on function comb in module scipy.misc.common:

comb(N, k, exact=0)
    Combinations of N things taken k at a time.

    If exact==0, then floating point precision is used, otherwise
    exact long integer is computed.

      - Array arguments accepted only for exact=0 case.
      - If k > N, N < 0, or k < 0, then a 0 is returned.

More information about the Python-list mailing list