Function combination

  • This method calculates the number of unordered subsets of k elements taken from a set of n elements, also known as 'n choose k'.

    Parameters

    • n: number

      Number of elements in set.

    • k: number

      Number of elements in subset.

    Returns f64

    • If n > k >= 0 : the number of unordered subsets of k elements taken from a set of n elements.
    • If k >= n : the value of n!/k!

    Remarks

    • The method uses the formula C(n,k) = n!/(k!(n-k)!) to calculate the number of combinations.
    • Requires n > k >= 0 to work properly. Otherwise, if k >= n, the method returns the value of n!/k!

Generated using TypeDoc