def comb(N, k, exact=False, repetition=False):
if repetition:<EOL><INDENT>return comb(N + k - <NUM_LIT:1>, k, exact)<EOL><DEDENT>if exact:<EOL><INDENT>N = int(N)<EOL>k = int(k)<EOL>if (k > N) or (N < <NUM_LIT:0>) or (k < <NUM_LIT:0>):<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>val = <NUM_LIT:1><EOL>for j in xrange(min(k, N-k)):<EOL><INDENT>val = (val*(N-j))//(j+<NUM_LIT:1>)<EOL><DEDENT>return val<EOL><DEDENT>else:<EOL><INDENT>k,N = asarray(k), asarray(N)<EOL>cond = (k <= N) & (N >= <NUM_LIT:0>) & (k >= <NUM_LIT:0>)<EOL>vals = binom(N, k)<EOL>if isinstance(vals, np.ndarray):<EOL><INDENT>vals[~cond] = <NUM_LIT:0><EOL><DEDENT>elif not cond:<EOL><INDENT>vals = np.float64(<NUM_LIT:0>)<EOL><DEDENT>return vals<EOL><DEDENT>
The number of combinations of N things taken k at a time.

This is often expressed as "N choose k".

Parameters
----------
N : int, ndarray
    Number of things.
k : int, ndarray
    Number of elements taken.
exact : bool, optional
    If `exact` is False, then floating point precision is used, otherwise
    exact long integer is computed.
repetition : bool, optional
    If `repetition` is True, then the number of combinations with
    repetition is computed.

Returns
-------
val : int, ndarray
    The total number of combinations.

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

Examples
--------
>>> k = np.array([3, 4])
>>> n = np.array([10, 10])
>>> sc.comb(n, k, exact=False)
array([ 120.,  210.])
>>> sc.comb(10, 3, exact=True)
120L
>>> sc.comb(10, 3, exact=True, repetition=True)
220L