{
  "category": "Math and trigonometry functions",
  "display_name": "COMBINA",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COMBINA",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20228",
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 40991,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 40991,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 40,991 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 40,995 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#L125-L127",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/combina.rs#L4-L45"
      ],
      "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#L125-L127",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 40,995 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COMBINA.json",
  "name": "COMBINA",
  "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- **[COMBIN](FUNC.COMBIN.md)** — the without-repetition count. The bridge identity\n  `COMBINA(n, k) = COMBIN(n+k-1, k)` means the two surfaces must agree on the same integer when\n  their arguments are matched up. They have different identified substrates, so that identity\n  is a metamorphic test rather than a tautology.\n- **`PERMUTATIONA`** — with-repetition and *ordered*: simply `n^k`. `PERMUT` is the ordered\n  without-repetition count. The four functions form the standard 2×2 of ordered/unordered\n  against with/without repetition.\n- **`GAMMALN`, `GAMMALN.PRECISE`, [EXP](FUNC.EXP.md)** — the identified substrate composition.\n  `EV-MATH-0017` reduces this surface's remaining error to the log-gamma surface's, which is\n  why the two pages should be read together.\n- **`NEGBINOM.DIST`** — the distribution whose mass function is exactly a multiset coefficient\n  times probabilities; the same evaluation problem appears there with a stability requirement.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nThe interesting fact about this surface is that its evaluation route has been **identified**,\nand identified by a single decisive witness rather than by a sweep.\n\nThe reasoning is worth stating because it is a model of how substrate identification works.\n`COMBINA(n, k)` is always an integer. A product of integers, evaluated in binary64, can round —\nbut it can only land on a representable neighbour of the true value, and while the true value\nis below `2^53` the exact integer *is* representable, so a product route hits it. `EV-MATH-0017`\nrecords a live witness in which Excel returns a value just below an exact integer that a product\nroute would have reached exactly. A product cannot produce that. An `exp(lnΓ)` composition can:\nthe logarithm loses the integrality, and the final exponentiation lands on whichever neighbour\nthe rounding chain reaches. The record therefore identifies the substrate as `exp(gammaln)` and\n**reduces `COMBINA` to the log-gamma wall** — meaning its residual error is not its own problem\nto solve but `GAMMALN`'s.\n\nTwo honest riders travel with that, both from the record itself: the reference implementation\ndoes *not* implement the identified substrate — it ships a product kernel — and the formal\nreduction to `GAMMALN` is a designed recipe that has not been executed.\n\nWhat a careful implementation does when it wants the *intended* function rather than the\nobserved bits:\n\n1. **Reduce to a binomial coefficient first**: `C(n+k-1, k)`, then apply the symmetry reduction\n   `k ← min(k, n-1)`. Never form the three factorials of the printed equation — `(N+M-1)!`\n   overflows at an argument sum of 171 while the answer may still be small.\n2. **Use the multiplicative recurrence** `acc ← acc·(n-1+i)/i`, whose every partial product is\n   itself a binomial coefficient and therefore an exact integer while it fits.\n3. **Return the exact integer below `2^53`.** This is achievable and is the property the\n   `exp(lnΓ)` route gives up.\n4. **Above `2^53`, the log-gamma route becomes attractive** for range reasons and immediately\n   inherits log-gamma's accuracy: an absolute error `ε` in `lnΓ` becomes a relative error of\n   about `ε` in the result, and `lnΓ` of a large argument is large, so a small *relative* error\n   in the logarithm is a much larger relative error in the answer. That amplification is the\n   wall the record names, and it is the standard reason (A&S chapter 6; Numerical Recipes\n   `bico`) that libraries which use `exp(factln)` document reduced accuracy for large binomials.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`, mathematically always a positive integer.\n\n- **`k = 0`** — one way to choose nothing: the value is 1.\n- **`n = 0`** — the printed equation reads `(M-1)!/(M!(-1)!)`, which is undefined for `M > 0`;\n  the documented constraint `N ≥ M` forces `M = 0` there, and `COMBINA(0, 0)` is conventionally\n  1. What Excel actually returns at `(0, 0)` is a documented-constraint boundary the Handbook\n  has not checked.\n- **Growth** — `COMBINA(n, k)` is `C(n+k-1, k)`, so it crosses the `2^53` exact-integer\n  threshold at modest arguments and overflows the double range not far beyond.\n- **A returned value that is not an integer is itself a finding.** Every value of this function\n  is an integer, so a fractional result cannot come from the mathematics. `EV-MATH-0017` turns\n  exactly this observation into a substrate identification (below).\n\nThe real-result policy axis records `arg_domain_guard=none; non_finite=allow` for this surface,\nwhich — as on `COMBIN` — sits uneasily beside a documented `#NUM!` domain condition. Recorded\nhere as a divergence, not resolved.\n\n\n\n### Errors\n\n\nAs documented on Microsoft's `COMBINA` page:\n\n| Error | Condition |\n|---|---|\n| `#NUM!` | The value of either argument is outside its documented constraints |\n| `#VALUE!` | Either argument is a non-numeric value |\n\nNote that the documented `#NUM!` condition is stated indirectly — \"outside of its constraints\"\n— so the exact trigger set is only as precise as the constraint list above it, and that list\nincludes the `N ≥ M` requirement this page flags as mathematically unnecessary.\n\n\n",
    "sources": "- Handbook evidence records `EV-MATH-0017` (substrate identified as `exp(gammaln)`; the product\n  kernel excluded; the reduction recipe designed and not executed) and `EV-MATH-0016` (the joint\n  discrepancy record). Read their reader warnings before their figures.\n- Feller, *An Introduction to Probability Theory and Its Applications*, volume I, chapter II —\n  the occupancy/stars-and-bars derivation.\n- Abramowitz & Stegun, chapter 24 — combinatorial analysis; chapter 6 for the log-gamma\n  accuracy context.\n- Press et al., *Numerical Recipes* — `bico`/`factln` and the stated large-argument caveat.\n- Handbook, [Coercion and lifting](../model/02-coercion-and-lifting.md).\n- Handbook projections `data/functions/FUNC.COMBINA.json` and `data/presence/FUNC.COMBINA.json`.\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 | 144 |\n| 20228 | Windows, 64-bit, CPU not recorded | 39,773 |\n| 20430 | Windows, 64-bit, CPU not recorded | 1,242 |\n\n- XC-COMBINA-001: build 19929 versus build 20228; 126 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-COMBINA-002: 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-COMBINA-003: build 20228 versus build 20430; 24 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.COMBINA.json).",
    "what-it-does": "\n`COMBINA(number, number_chosen)` counts **combinations with repetition**: the number of ways to\nchoose `k` items from `n` types when the same type may be chosen more than once and order does\nnot matter. This is the multiset coefficient, written `((n choose k))` in Stanley's notation.\n\nMicrosoft's page prints the equation directly, with `N` for *number* and `M` for\n*number_chosen*:\n\n    COMBINA(N, M) = (N + M - 1)! / ( M! (N - 1)! )\n\nwhich is the same thing as the binomial coefficient\n\n    COMBINA(n, k) = C(n + k - 1, k) = C(n + k - 1, n - 1)\n\nThe identity is the *stars and bars* argument: a multiset of size `k` drawn from `n` types is\ndetermined by where you place `n - 1` dividers among `k + n - 1` positions.\n\n| Property | Statement |\n|---|---|\n| Domain (documented) | `n ≥ 0`, `k ≥ 0`, and `n ≥ k` |\n| Range | positive integers |\n| Reduction | `COMBINA(n, k) = C(n+k-1, k)` — a binomial coefficient, always |\n| Boundary | `COMBINA(n, 0) = 1`; `COMBINA(1, k) = 1`; `COMBINA(n, 1) = n` |\n| Generating function | `1/(1-x)^n = Σ_k COMBINA(n, k) x^k` |\n| Symmetry | none in `(n, k)`; the underlying binomial's symmetry is `k ↔ n-1` |\n\nOne documentation observation belongs here rather than buried below, because it is a genuine\ndivergence between the mathematics and the published constraint. **The multiset coefficient is\ndefined for every `n ≥ 1` and every `k ≥ 0`, with no requirement that `n ≥ k`** — choosing five\nscoops from three flavours is a perfectly ordinary question, and the answer is `C(7, 5) = 21`.\nMicrosoft's page nevertheless documents *Number* as having to be \"greater than or equal to\nNumber_chosen\", and documents `#NUM!` when an argument is outside its constraints. Either Excel\nrefuses a well-posed combinatorial question, or the documented constraint is stricter than the\nimplementation. The Handbook has not checked which, and it is the first probe listed below.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Constraint (as documented) |\n|---|---|---|\n| `number` (`N`) | The number of item **types** available. Required. | `≥ 0`, and `≥ number_chosen` |\n| `number_chosen` (`M`) | The number of items chosen. Required. | `≥ 0` |\n\nMicrosoft states that **non-integer values are truncated** in both positions, and that a\nnon-numeric value in either position gives `#VALUE!`.\n\n"
  },
  "signature": {
    "display": "COMBINA(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 items may repeat and order does not matter",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the number of combinations with repetitions for a given number of items",
        "microsoft_url": "https://support.microsoft.com/en-us/office/combina-function-efb49eaa-4f4c-4cd2-8179-0ddfcf9d035d"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COMBINA"
        },
        {
          "locale": "bg-BG",
          "name": "COMBINA"
        },
        {
          "locale": "cs-CZ",
          "name": "COMBINA"
        },
        {
          "locale": "da-DK",
          "name": "KOMBINA"
        },
        {
          "locale": "de-DE",
          "name": "COMBINA"
        },
        {
          "locale": "el-GR",
          "name": "COMBINA"
        },
        {
          "locale": "en-AU",
          "name": "COMBINA"
        },
        {
          "locale": "en-GB",
          "name": "COMBINA"
        },
        {
          "locale": "en-US",
          "name": "COMBINA"
        },
        {
          "locale": "es-ES",
          "name": "COMBINA"
        },
        {
          "locale": "et-EE",
          "name": "COMBINA"
        },
        {
          "locale": "fi-FI",
          "name": "KOMBINAATIO"
        },
        {
          "locale": "fr-FR",
          "name": "COMBINA*"
        },
        {
          "locale": "he-IL",
          "name": "COMBINA"
        },
        {
          "locale": "hr-HR",
          "name": "COMBINA"
        },
        {
          "locale": "hu-HU",
          "name": "KOMBINÁCIÓK.ISM"
        },
        {
          "locale": "id-ID",
          "name": "COMBINA"
        },
        {
          "locale": "it-IT",
          "name": "COMBINA"
        },
        {
          "locale": "ja-JP",
          "name": "COMBINA"
        },
        {
          "locale": "ko-KR",
          "name": "COMBINA"
        },
        {
          "locale": "lt-LT",
          "name": "COMBINA"
        },
        {
          "locale": "lv-LV",
          "name": "COMBINA"
        },
        {
          "locale": "nb-NO",
          "name": "COMBINA"
        },
        {
          "locale": "nl-NL",
          "name": "COMBIN.A"
        },
        {
          "locale": "pl-PL",
          "name": "KOMBINACJE.A"
        },
        {
          "locale": "pt-BR",
          "name": "COMBINA"
        },
        {
          "locale": "pt-PT",
          "name": "COMBIN.R"
        },
        {
          "locale": "ro-RO",
          "name": "COMBINA"
        },
        {
          "locale": "ru-RU",
          "name": "ЧИСЛКОМБА"
        },
        {
          "locale": "sk-SK",
          "name": "COMBINA"
        },
        {
          "locale": "sl-SI",
          "name": "COMBINA"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COMBINA"
        },
        {
          "locale": "sv-SE",
          "name": "KOMBINA"
        },
        {
          "locale": "th-TH",
          "name": "COMBINA"
        },
        {
          "locale": "tr-TR",
          "name": "KOMBİNASYONA"
        },
        {
          "locale": "uk-UA",
          "name": "COMBINA"
        },
        {
          "locale": "vi-VN",
          "name": "COMBINA"
        },
        {
          "locale": "zh-CN",
          "name": "COMBINA"
        },
        {
          "locale": "zh-HK",
          "name": "COMBINA"
        },
        {
          "locale": "zh-TW",
          "name": "COMBINA"
        }
      ],
      "signature": {
        "display": "COMBINA(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": "COMBINA",
      "version_marker": null,
      "xlcall": {
        "code": "568",
        "symbol": "xlfCombina"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/combina-function-efb49eaa-4f4c-4cd2-8179-0ddfcf9d035d"
  },
  "try_it": {
    "formula": "=COMBINA(0, 0)"
  },
  "url": "https://handbook.dnacalc.com/functions/COMBINA.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "144 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.COMBINA.json"
      ]
    },
    {
      "behaviour": "39,773 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.COMBINA.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.COMBINA.json"
      ]
    }
  ]
}