nCk ( n k -- nCk ) (original) (raw)

nCk ( n k -- nCk )

Vocabulary
math.combinatorics

Inputs

n a non-negative integer
k a non-negative integer

Outputs

nCk an integer

Word description
Outputs the total number of unique combinations of size k (order does not matter) that can be taken from a set of size n. Commonly written as "n choose k".

Examples

USING: math.combinatorics prettyprint ; 10 4 nCk .
210

Definition

USING: kernel math math.combinatorics.private ;

IN: math.combinatorics

: nCk ( n k -- nCk ) twiddle [ nPk ] keep factorial /i ;