nPk ( n k -- nPk )


Vocabulary
math.combinatorics

Inputs and outputs
na non-negative integer
ka non-negative integer
nPkan integer


Word description
Outputs the total number of unique permutations of size k (order does matter) that can be taken from a set of size n.

Examples
USING: math.combinatorics prettyprint ; 10 4 nPk .
5040


Definition
USING: kernel math math.combinatorics.private math.ranges
sequences ;

IN: math.combinatorics

: nPk ( n k -- nPk )
2dup possible? [ dupd - [a,b) product ] [ 2drop 0 ] if ;