comb_fl()

Calculate C(n, k)

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

Note

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

Syntax

comb_fl(n, k)

Arguments

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

Usage

comb_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 comb_fl=(n:int, k:int)
{
    let fact_n = gamma(n+1);
    let fact_nk = gamma(n-k+1);
    let fact_k = gamma(k+1);
    tolong(fact_n/fact_nk/fact_k)
}
;
range n from 3 to 10 step 3
| extend k = n-2
| extend cnk = comb_fl(n, k)
n	k	cnk
3	1	3
6	4	15
9	7	36