perm_fl()

Calculate P(n, k)

The function perm_fl()calculates P(n, k), the number of permutations for selection of k items out of n, with order. It is based on the Azure Data Explorer native gamma() function to calculate factorial, (see facorial_fl()). For selection of k items without order, use comb_fl()

Note

This function is a UDF (user-defined function). For more information, see usage.

Syntax

perm_fl(n, k)

Arguments

  • n: Total number of items.
  • k: Selected number of items.

Usage

perm_fl() is a user-defined function. You can either embed its code in your query, or install it in your database. There are two usage options: ad hoc and persistent usage. See the below tabs for examples.

For ad hoc usage, embed its code using a let statement. No permission is required.

let perm_fl=(n:int, k:int)
{
    let fact_n = gamma(n+1);
    let fact_nk = gamma(n-k+1);
    tolong(fact_n/fact_nk)
}
;
range n from 3 to 10 step 3
| extend k = n-2
| extend pnk = perm_fl(n, k)
n	k	pnk
3	1	3
6	4	360
9	7	181440