# scipy.special.comb¶

scipy.special.comb(N, k, exact=False, repetition=False)[source]

The number of combinations of N things taken k at a time.

This is often expressed as “N choose k”.

Parameters
Nint, ndarray

Number of things.

kint, ndarray

Number of elements taken.

exactbool, optional

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

repetitionbool, optional

If repetition is True, then the number of combinations with repetition is computed.

Returns
valint, float, ndarray

The total number of combinations.

binom

Binomial coefficient ufunc

Notes

• Array arguments accepted only for exact=False case.

• If N < 0, or k < 0, then 0 is returned.

• If k > N and repetition=False, then 0 is returned.

Examples

>>> from scipy.special import comb
>>> k = np.array([3, 4])
>>> n = np.array([10, 10])
>>> comb(n, k, exact=False)
array([ 120.,  210.])
>>> comb(10, 3, exact=True)
120L
>>> comb(10, 3, exact=True, repetition=True)
220L


#### Previous topic

scipy.special.keip_zeros

#### Next topic

scipy.special.perm
{"ft_lang_label":"__label__en","ft_lang_prob":0.6315053,"math_prob":0.93504775,"size":997,"snap":"2019-51-2020-05","text_gpt3_token_len":274,"char_repetition_ratio":0.13796575,"word_repetition_ratio":0.0,"special_character_ratio":0.29388165,"punctuation_ratio":0.21568628,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9969534,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-23T22:49:56Z\",\"WARC-Record-ID\":\"<urn:uuid:072cc5a7-e88e-481b-8bca-1bea1742e127>\",\"Content-Length\":\"10236\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7e381c18-efbc-4045-8670-984c806d1c0a>\",\"WARC-Concurrent-To\":\"<urn:uuid:4aa901cc-79fd-458a-87b8-199af787ba5e>\",\"WARC-IP-Address\":\"185.199.110.153\",\"WARC-Target-URI\":\"http://scipy.github.io/devdocs/generated/scipy.special.comb.html\",\"WARC-Payload-Digest\":\"sha1:JZ43PUZHZULI7LCGGXA4OAPBJ33RDTM5\",\"WARC-Block-Digest\":\"sha1:7GHXPQUF667GWRWIYUUB7TZ52JP5A2OM\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579250614086.44_warc_CC-MAIN-20200123221108-20200124010108-00109.warc.gz\"}"}