{
  "category": "Math and trigonometry functions",
  "display_name": "COMBIN",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COMBIN",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131",
        "20228",
        "20430",
        "?"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 25199,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 25199,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 25,199 in the answer bank and 4 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 25,203 recorded answers",
    "workbook_corpus": {
      "cells": 4,
      "matched": 4
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L122-L124"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "ported/combin::combin_kernel",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_div",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::div",
        "ported/factorial_common::trunc_nonnegative"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L122-L124",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 25,203 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COMBIN.json",
  "name": "COMBIN",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **[COMBINA](FUNC.COMBINA.md)** — the with-repetition sibling, `COMBINA(n, k) = C(n+k-1, k)`.\n  The two are joined by that single identity and separated by very different evidence: see the\n  numerical notes on both pages.\n- **`PERMUT`** — the ordered count, `P(n, k) = n! / (n-k)!`, related by\n  `P(n, k) = C(n, k) · k!`. `PERMUTATIONA` is its with-repetition partner, `n^k`.\n- **[FACT](FUNC.FACT.md)** — the factorial the documented formula is written in. Evaluating\n  `COMBIN` *as* that formula is the one implementation choice you should not make; see below.\n- **`GAMMALN`, `GAMMALN.PRECISE`** — the log-gamma route, `C(n,k) = exp(lnΓ(n+1) − lnΓ(k+1) −\n  lnΓ(n-k+1))`, which is how many libraries evaluate large binomials and which is identified\n  as the substrate for `COMBINA` but *not* for `COMBIN`.\n- **`HYPGEOM.DIST`, `BINOM.DIST`** — the distribution functions whose mass functions are\n  binomial coefficients times probabilities; they usually need better than a `COMBIN` product.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nThe naive route — form `n!`, `k!` and `(n-k)!`, then divide — is the formula Microsoft prints\nand the algorithm nobody should ship. It overflows at `n = 171` even when the answer is tiny\n(`C(200, 1)` is 200), and it throws away exactness long before that.\n\nThe standard remedies, in the order a careful implementation applies them:\n\n1. **Reduce by symmetry**: replace `k` with `min(k, n-k)`. This halves the worst-case work and,\n   more importantly, shortens the product that accumulates rounding. `EV-MATH-0016` records\n   this reduction as a *confirmed structural finding about Excel* — one of the few things about\n   this surface that is settled.\n2. **Use the multiplicative recurrence with the division inside the loop**:\n   `acc ← acc · (n-k+i) / i` for `i = 1 … k`. Each partial product is itself a binomial\n   coefficient, hence an exact integer while it fits, so the intermediate never overflows\n   earlier than the result does. The alternative \"multiply everything, divide once\" ordering\n   overflows spuriously.\n3. **Return exact integers where they fit.** Below `2^53` the answer is representable and an\n   integer-arithmetic path can return it exactly.\n4. **Above `2^53`, choose and document a rounding discipline.** This is where implementations\n   diverge, and it is where the evidence sits.\n\nThe evidence attached to this page — `EV-MATH-0016` and `EV-MISC-0015` — records a capture\nbuilt specifically to *discriminate* between candidate op-graphs, and its result is negative in\nan unusually informative way. An earlier claim that this surface agreed with Excel below `2^53`\nwas **withdrawn**, because it rested on a corpus that could not tell the candidates apart. On\nthe discriminating pairs, the ruled-out list covers every product-loop family in both\ndirections, strict and per-step double-rounded and fully extended orderings, factorial-ratio\nforms, reciprocal-multiply forms, and compositions of the published `GAMMALN`. Plain-double and\nx87 extended-precision product orderings score identically. The record states plainly that the\nop-graph is unidentified, that a subset of the discriminating rows is matched by no candidate\nform at all, and that Excel sits *below* the multiply-first product at larger `n` and `k`. The\nfigures belong to the evidence layer and render beside this page; the shape of the finding is\nthe part that belongs in prose.\n\nThe literature context: A&S chapter 24 gives the identity set; Knuth volume 1 §1.2.6 is the\nstandard source for the symmetry-and-multiplicative-recurrence discipline; Numerical Recipes'\n`bico` uses the `exp(factln)` route and states its own accuracy caveat, which is exactly the\nroute ruled out for this surface and identified for its sibling.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`, mathematically always a positive integer.\n\n- **`k = 0` or `k = n`** — the value is 1, including the vacuous `C(0, 0) = 1`.\n- **Non-integer arguments** — documented to truncate toward zero before the count is formed.\n- **Results above `2^53`** — the exact combinatorial answer is no longer representable as a\n  binary64 integer, so *some* rounding is unavoidable in any implementation. What is not\n  unavoidable is *which* representable neighbour you land on, and that is the whole content of\n  the evidence attached to this page.\n- **Results above the largest finite double** — the mathematics overflows. The reference\n  engine's real-result policy for this surface records `non_finite=allow`, meaning a non-finite\n  result would be published rather than converted to an error. That is a divergence worth\n  naming: `EV-MATH-0008` records the \"Excel never publishes an infinity\" convention for a\n  named list of surfaces, and `COMBIN` is not on that list. Nobody has checked what Excel\n  returns when the binomial coefficient overflows.\n\nLogicals, text-that-looks-numeric, blanks and error arguments follow the shared call model; the\nmechanically rendered battery beside this page shows the boundary probes for those kinds.\n\n\n\n### Errors\n\n\nAs documented on Microsoft's `COMBIN` page:\n\n| Error | Condition |\n|---|---|\n| `#VALUE!` | Either argument is nonnumeric |\n| `#NUM!` | `number < 0`, or `number_chosen < 0`, or `number < number_chosen` |\n\n",
    "sources": "- Handbook evidence records `EV-MATH-0016` and `EV-MISC-0015` — the discriminating capture, the\n  withdrawn prior claim, the confirmed `k → min(k, n-k)` reduction, and the ruled-out candidate\n  families. Read their reader warnings before reading their counts.\n- Abramowitz & Stegun, *Handbook of Mathematical Functions*, chapter 24 — combinatorial\n  analysis and the binomial identity set.\n- Knuth, *TAOCP* volume 1 §1.2.6 — binomial coefficient identities and evaluation discipline.\n- Press et al., *Numerical Recipes* — `bico`/`factln`, the exp(log-gamma) route.\n- Handbook, [Coercion and lifting](../model/02-coercion-and-lifting.md) and\n  [The value universe](../model/01-value-universe.md).\n- Handbook projections `data/functions/FUNC.COMBIN.json` (arity, classification, the\n  `arg_domain_guard=none` and `non_finite=allow` axis values) and\n  `data/presence/FUNC.COMBIN.json` (implementing module, defect-stream mentions).\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 19929 | Windows, bitness not recorded, CPU not recorded | 148 |\n| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 503 |\n| 20228 | Windows, 64-bit, CPU not recorded | 23,468 |\n| 20430 | Windows, 64-bit, CPU not recorded | 1,242 |\n\n- XC-COMBIN-001: build 19929 versus build 20131; 4 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.\n- XC-COMBIN-002: build 19929 versus build 20228; 103 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.\n- XC-COMBIN-003: build 19929 versus build 20430; 2 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.\n- XC-COMBIN-004: build 20131 versus build 20228; 503 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.\n- XC-COMBIN-005: build 20131 versus build 20228; 503 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.\n- XC-COMBIN-006: build 20228 versus build 20430; 14 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.\n\nAgreement on these compared inputs does not establish agreement on unmeasured inputs.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COMBIN.json).",
    "what-it-does": "\n`COMBIN(number, number_chosen)` is the binomial coefficient. Writing `n` for *number* and `k`\nfor *number_chosen*, Microsoft's page states the defining formula directly:\n\n    C(n, k) = n! / ( k! (n-k)! )\n\nIt counts the subsets of size `k` of a set of size `n` — sets, so internal order does not\nmatter. Microsoft's page draws exactly that contrast: combinations are distinct from\npermutations, \"for which the internal order is significant\".\n\nThe properties that matter for reading and for implementing:\n\n| Property | Statement |\n|---|---|\n| Domain | integers with `0 ≤ k ≤ n` (see Arguments for the truncation rule) |\n| Range | positive integers; `C(n, k) ≥ 1` on the whole domain |\n| Symmetry | `C(n, k) = C(n, n-k)` |\n| Pascal recurrence | `C(n, k) = C(n-1, k-1) + C(n-1, k)` |\n| Multiplicative recurrence | `C(n, k) = C(n, k-1) · (n-k+1) / k` |\n| Row sum | `Σ_k C(n, k) = 2^n` |\n| Boundary | `C(n, 0) = C(n, n) = 1`, and `C(0, 0) = 1` |\n| Generating function | `(1 + x)^n = Σ_k C(n, k) x^k` |\n\nTwo consequences shape everything downstream. First, **the true value is always an integer**,\nso any returned value with a fractional part is evidence about the evaluation route rather than\nabout the mathematics. Second, the values grow fast: the central coefficient `C(n, ⌊n/2⌋)` is\nasymptotically `2^n / √(πn/2)`, so it passes `2^53` — the last integer beyond which binary64\ncannot represent every integer — in the high fifties, and passes the largest finite double\nsomewhat past `n = 1000`. Every interesting question about this function lives above the first\nthreshold and below the second.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Constraint (as documented) |\n|---|---|---|\n| `number` (`n`) | The number of items. Required. | `n ≥ 0`, `n ≥ k` |\n| `number_chosen` (`k`) | The number of items in each combination. Required. | `k ≥ 0` |\n\n"
  },
  "signature": {
    "display": "COMBIN(number, number_chosen)",
    "parameters": [
      {
        "description": null,
        "name": "number",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "number_chosen",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 2
      },
      "category": "Math and trigonometry functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "UnaryNumericScalarOnly",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "NumsToNum",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Number of ways to pick k items from n when order does not matter",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the number of combinations for a given number of objects",
        "microsoft_url": "https://support.microsoft.com/en-us/office/combin-function-12a3f276-0a21-423a-8de6-06990aaf638a"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COMBIN"
        },
        {
          "locale": "bg-BG",
          "name": "COMBIN"
        },
        {
          "locale": "cs-CZ",
          "name": "KOMBINACE"
        },
        {
          "locale": "da-DK",
          "name": "KOMBIN"
        },
        {
          "locale": "de-DE",
          "name": "COMBIN"
        },
        {
          "locale": "el-GR",
          "name": "COMBIN"
        },
        {
          "locale": "en-AU",
          "name": "COMBIN"
        },
        {
          "locale": "en-GB",
          "name": "COMBIN"
        },
        {
          "locale": "en-US",
          "name": "COMBIN"
        },
        {
          "locale": "es-ES",
          "name": "COMBINAT"
        },
        {
          "locale": "et-EE",
          "name": "COMBIN"
        },
        {
          "locale": "fi-FI",
          "name": "KOMBINAATIO"
        },
        {
          "locale": "fr-FR",
          "name": "COMBIN*"
        },
        {
          "locale": "he-IL",
          "name": "COMBIN"
        },
        {
          "locale": "hr-HR",
          "name": "COMBIN"
        },
        {
          "locale": "hu-HU",
          "name": "KOMBINÁCIÓK"
        },
        {
          "locale": "id-ID",
          "name": "COMBIN"
        },
        {
          "locale": "it-IT",
          "name": "COMBIN"
        },
        {
          "locale": "ja-JP",
          "name": "COMBIN"
        },
        {
          "locale": "ko-KR",
          "name": "COMBIN"
        },
        {
          "locale": "lt-LT",
          "name": "COMBIN"
        },
        {
          "locale": "lv-LV",
          "name": "COMBIN"
        },
        {
          "locale": "nb-NO",
          "name": "COMBIN"
        },
        {
          "locale": "nl-NL",
          "name": "COMBINATIES"
        },
        {
          "locale": "pl-PL",
          "name": "KOMBINACJE"
        },
        {
          "locale": "pt-BR",
          "name": "COMBINAR"
        },
        {
          "locale": "pt-PT",
          "name": "COMBIN"
        },
        {
          "locale": "ro-RO",
          "name": "COMBIN"
        },
        {
          "locale": "ru-RU",
          "name": "ЧИСЛКОМБ"
        },
        {
          "locale": "sk-SK",
          "name": "COMBIN"
        },
        {
          "locale": "sl-SI",
          "name": "COMBIN"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COMBIN"
        },
        {
          "locale": "sv-SE",
          "name": "KOMBIN"
        },
        {
          "locale": "th-TH",
          "name": "COMBIN"
        },
        {
          "locale": "tr-TR",
          "name": "KOMBİNASYON"
        },
        {
          "locale": "uk-UA",
          "name": "COMBIN"
        },
        {
          "locale": "vi-VN",
          "name": "COMBIN"
        },
        {
          "locale": "zh-CN",
          "name": "COMBIN"
        },
        {
          "locale": "zh-HK",
          "name": "COMBIN"
        },
        {
          "locale": "zh-TW",
          "name": "COMBIN"
        }
      ],
      "signature": {
        "display": "COMBIN(number, number_chosen)",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "number_chosen",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "COMBIN",
      "version_marker": null,
      "xlcall": {
        "code": "276",
        "symbol": "xlfCombin"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/combin-function-12a3f276-0a21-423a-8de6-06990aaf638a"
  },
  "try_it": {
    "formula": "=COMBIN(10,3)"
  },
  "url": "https://handbook.dnacalc.com/functions/COMBIN.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "148 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 19929",
      "platform": "Windows, bitness not recorded, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COMBIN.json"
      ]
    },
    {
      "behaviour": "503 captured inputs are indexed for this environment. Capture dates: 2026-07-11 to 2026-07-11. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20131",
      "platform": "Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COMBIN.json"
      ]
    },
    {
      "behaviour": "23,468 captured inputs are indexed for this environment. Capture dates: 2026-08-09 to 2026-08-09. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20228",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COMBIN.json"
      ]
    },
    {
      "behaviour": "1,242 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COMBIN.json"
      ]
    }
  ]
}