matician - v2.0.0
    Preparing search index...

    Function combinations

    • Calculates the number of combinations of k items chosen from n items. If replacement is true, computes with replacement: (n + k - 1) choose k. If false, computes without replacement: n choose k.

      Parameters

      • n: number

        Total number of items (n ≥ 0)

      • k: number

        Number of items to choose (k ≥ 0)

      • replacement: boolean = true

        Whether replacement is allowed (default: true)

      Returns number

      The number of combinations

      combinations(5, 3); // 35 (with replacement)
      combinations(5, 3, false); // 10 (no replacement)