{
  "category": "Math and trigonometry functions",
  "display_name": "LCM",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.LCM",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 7967,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 7967,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 7,967 in the answer bank and 6 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 7,973 recorded answers",
    "workbook_corpus": {
      "cells": 6,
      "matched": 6
    }
  },
  "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#L138-L141",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/gcd_lcm_common.rs#L14-L29",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/lcm_fn.rs#L4-L16"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/math::integer_groups",
        "ported/gcd_lcm_common::gcd_int"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L138-L141",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 7,973 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.LCM.json",
  "name": "LCM",
  "notes": [
    {
      "basis": "All recorded rows match after the boundary change: GCD 7,966 of 7,966 and LCM 7,967 of 7,967.",
      "documentation": {
        "claim": "If a parameter to GCD is >=2^53, GCD returns the #NUM! error value. If LCM(a,b) >=2^53, LCM returns the #NUM! error value.",
        "source": "https://support.microsoft.com/en-us/office/gcd-function-d5107a51-69e3-461f-8e4c-ddfc21b5073a; https://support.microsoft.com/en-us/office/lcm-function-7152b67a-8bb5-4075-ae5c-06ede5563c94"
      },
      "evidence": [
        {
          "commit": "9c23dde1dfd6d93e742d763a4bad3eaec229b29c",
          "locator": "recorded_gcd_lcm_admit_the_exact_operand_boundary",
          "note": "recorded readings pinned",
          "path": "apps/dna-onecalc/tests/acceptance.rs",
          "repository": "DnaCalc"
        }
      ],
      "functions": [
        "FUNC.GCD",
        "FUNC.LCM"
      ],
      "inferred": null,
      "kind": "documentation-differs",
      "note_id": "FN-GCD-001",
      "open": [],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "GCD(9007199254740992, 1)",
          "correct": null,
          "excel": {
            "bits": "0x3ff0000000000000",
            "display": "1",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number1",
              "value": {
                "bits": "0x4340000000000000",
                "display": "9007199254740992",
                "kind": "number"
              }
            },
            {
              "name": "number2",
              "value": {
                "bits": "0x3ff0000000000000",
                "display": "1",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111boundary-GCD-00190",
            "note": null,
            "path": "runs/w111-integer-publication-20260929/answers/answers-gcd.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "LCM(9007199254740992, 2)",
          "correct": null,
          "excel": {
            "bits": "0x4340000000000000",
            "display": "9007199254740992",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number1",
              "value": {
                "bits": "0x4340000000000000",
                "display": "9007199254740992",
                "kind": "number"
              }
            },
            {
              "name": "number2",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111boundary-LCM-00194",
            "note": null,
            "path": "runs/w111-integer-publication-20260929/answers/answers-lcm.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        },
        {
          "call": "GCD(9007199254740994, 0)",
          "correct": null,
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number1",
              "value": {
                "bits": "0x4340000000000001",
                "display": "9007199254740994",
                "kind": "number"
              }
            },
            {
              "name": "number2",
              "value": {
                "bits": "0x0000000000000000",
                "display": "0",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture",
          "source": {
            "commit": "4d5320dfdc385354469b4d506153357bb932ab08",
            "locator": "w111boundary-GCD-00217",
            "note": null,
            "path": "runs/w111-integer-publication-20260929/answers/answers-gcd.json.gz",
            "repository": "CalcFunc-Evidence"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "GCD accepts an operand equal to 2^53, and LCM accepts an operand or a result equal to 2^53. Only values above 2^53 give #NUM!.",
      "status": "measured",
      "title": "GCD and LCM accept 2^53 itself, not only values below it"
    }
  ],
  "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- **[MOD](FUNC.MOD.md)** — the divisibility primitive underneath both.\n- **`MULTINOMIAL`** — the other variadic exact-integer function in this\n  category, sharing `LCM`'s group structural evidence record and its 2^53-scale\n  representability problem.\n- Readers most often reach for `LCM` for common denominators and for period alignment (\"both\n  events recur together every `LCM(m, n)` steps\"). Both usages sit far below the documented\n  ceiling, which is why the ceiling is rarely met in practice and rarely tested.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nLike `GCD`, `LCM` computes exactly in its intended domain — there is no rounding error to\nanalyse — and like `GCD` its real hazard is representability. Unlike `GCD`, the hazard is\nreached from *inside* the admissible domain, because the lcm of admissible arguments is not\nitself guaranteed admissible.\n\n**Compute in the order that does not overflow.** The naive binary step\nlcm(*a*, *b*) = *a* · *b* / gcd(*a*, *b*) forms the product first, and that product can exceed\n2^53 — or exceed the machine word — even when the final answer is comfortably small. The\nstandard remedy is to divide first:\n\n    lcm(a, b) = (a / gcd(a, b)) * b\n\nThe division is exact because gcd(*a*, *b*) divides *a*, so no precision is lost, and the\nlargest intermediate is the answer itself rather than the product of the inputs. Any\nimplementation that forms `a*b` before dividing has a smaller usable domain than the one it\nadvertises, and its failures appear as silently wrong values rather than as errors when the\narithmetic wraps.\n\n**The fold accumulates.** With many arguments the running lcm grows monotonically, so an\noverflow check belongs *inside* the fold, tested after each step, not once at the end. Checking\nonly the final value cannot detect an intermediate that already wrapped.\n\n**The 2^53 wall.** Above 2^53 consecutive integers are no longer distinct doubles, so an lcm\nreturned as a binary64 above that point is not the integer it claims to be — it is the nearest\nrepresentable neighbour, and it may not even be a multiple of the inputs. Microsoft's documented\n`#NUM!` is a refusal to hand back a value whose defining property has stopped holding. That is\nthe right instinct, and it is worth stating plainly: above the wall the *postcondition* fails,\nnot merely the precision.\n\nKnuth, *The Art of Computer Programming*, volume 2, section 4.5.2 covers the gcd algorithms\nthis function's inner loop rests on; the divide-before-multiply discipline is standard advice in\nevery treatment of exact integer arithmetic.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number` — a non-negative integer value.\n\n- **Zero alone** yields zero, consistent with zero as the absorbing element.\n- **A logical argument** is converted and accepted; **numeric text** is converted and then\n  truncated. Microsoft's page addresses neither case, speaking only of \"nonnumeric\".\n- **An inline array** is reduced to one result rather than lifted elementwise.\n- **An empty range** produces `#VALUE!`.\n- **A subnormal magnitude** truncates to zero, and zero absorbs — so a single tiny positive\n  argument turns the whole result into zero. That is mathematically right and practically\n  surprising, and it is the failure mode to watch for when `LCM` is fed computed values rather\n  than typed constants.\n\n\n\n### Errors\n\n\nAs documented on Microsoft's `LCM` page:\n\n| Error | Documented condition |\n|---|---|\n| `#VALUE!` | \"If any argument is nonnumeric, LCM returns the #VALUE! error value.\" |\n| `#NUM!` | \"If any argument is less than zero, LCM returns the #NUM! error value.\" |\n| `#NUM!` | \"If LCM(a,b) >=2^53, LCM returns the #NUM! error value.\" |\n\nError values in any argument propagate under the shared coercion discipline.\n\nNote the wording of the third row and compare it with [GCD](FUNC.GCD.md)'s: `GCD`'s ceiling is\ntested on any **parameter**, `LCM`'s on the **result**. The asymmetry is not an editorial\naccident — a gcd is bounded above by its smallest argument and can never overflow inputs that\nwere themselves admissible, whereas an lcm of two modest coprime arguments is their product and\nreaches 2^53 quickly. `LCM` is therefore the member of the pair that must test *after* computing,\nwhich means it must either detect the overflow during the fold or compute in a wider type.\n\n",
    "sources": "- Microsoft, \"LCM function\" —\n  <https://support.microsoft.com/en-us/office/lcm-function-7152b67a-8bb5-4075-ae5c-06ede5563c94>.\n  Retrieved for this page: the syntax, the \"1 to 255 values\" count, the truncation rule, the\n  `#VALUE!` nonnumeric remark, the `#NUM!` negative remark, the `#NUM!` on the result at 2^53,\n  and the common-denominator motivation.\n- Handbook, [coercion and lifting](../model/02-coercion-and-lifting.md) — to-number outcomes,\n  the aggregate-versus-lift distinction, error propagation.\n- D. E. Knuth, *The Art of Computer Programming*, volume 2, section 4.5.2 — gcd algorithms and\n  exact integer reduction.\n\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| 20430 | Windows, 64-bit, CPU not recorded | 7,967 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.LCM.json).",
    "what-it-does": "\n`LCM(number1, [number2], ...)` returns the least common multiple of its arguments after each\nhas been truncated to an integer.\n\nFor positive integers *a*, *b*, lcm(*a*, *b*) is the smallest positive integer that both\ndivide. As with gcd, the *n*-argument function is the associative fold:\n\n    lcm(a, b, c) = lcm(lcm(a, b), c)\n\nThe structural facts worth carrying:\n\n- **lcm(*a*, 0) = 0**, and lcm(*a*, 1) = *a*. Zero is the absorbing element of the join, one is\n  its identity — exactly the mirror of gcd, where zero is the identity.\n- **The two-argument identity** gcd(*a*, *b*) · lcm(*a*, *b*) = *a* · *b* holds for\n  non-negative integers. **It does not generalize to three or more arguments**: the product of\n  gcd and lcm of a triple is not the product of the triple. The correct three-argument identity\n  runs through the inclusion–exclusion of prime exponents, not through a single product, and\n  every attempt to compute a three-way lcm as \"product over gcd\" is wrong. This is the single\n  most common error in worksheet code that reimplements `LCM`.\n- **In prime-exponent form**, lcm takes the pointwise maximum of the exponent vectors and gcd\n  the pointwise minimum. That is the whole theory: gcd is the meet, lcm the join, of the\n  divisibility lattice.\n- Microsoft's page gives the practical motivation: the least common multiple is what you need to\n  add fractions with unlike denominators.\n\nDomain: non-negative integers after truncation. Range: non-negative integers.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Required |\n|---|---|---|\n| `number1` | The first value. | Yes |\n| `number2`, … | Further values. | No |\n\nTruncation happens before the arithmetic. `LCM(2.9, 3)` is the lcm of 2 and 3. On the\nadmissible non-negative domain, truncation and floor agree, so the negative-number ambiguity\nthat separates truncation from flooring elsewhere in this category cannot arise here.\n\nArgument slots are numeric and subject to ordinary to-number coercion\n([coercion and lifting](../model/02-coercion-and-lifting.md)). Range and array arguments are\nscanned and reduced to a single result; `LCM` is declared with a custom coercion profile, not\nthe scalar-lift profile, so it does not apply elementwise.\n\n\n"
  },
  "signature": {
    "display": "LCM(number1, [number2], ...)",
    "parameters": [
      {
        "description": null,
        "name": "number1",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "number2",
        "optional": true,
        "repeats": true
      }
    ],
    "trailing_repeats": true
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 255,
        "min": 1
      },
      "category": "Math and trigonometry functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Least common multiple of whole numbers",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the least common multiple",
        "microsoft_url": "https://support.microsoft.com/en-us/office/lcm-function-7152b67a-8bb5-4075-ae5c-06ede5563c94"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "LCM"
        },
        {
          "locale": "bg-BG",
          "name": "LCM"
        },
        {
          "locale": "cs-CZ",
          "name": "LCM"
        },
        {
          "locale": "da-DK",
          "name": "MINDSTE.FÆLLES.MULTIPLUM"
        },
        {
          "locale": "de-DE",
          "name": "LCM"
        },
        {
          "locale": "el-GR",
          "name": "LCM"
        },
        {
          "locale": "en-AU",
          "name": "LCM"
        },
        {
          "locale": "en-GB",
          "name": "LCM"
        },
        {
          "locale": "en-US",
          "name": "LCM"
        },
        {
          "locale": "es-ES",
          "name": "M.C.M"
        },
        {
          "locale": "et-EE",
          "name": "LCM"
        },
        {
          "locale": "fi-FI",
          "name": "PIENIN.YHT.JAETTAVA"
        },
        {
          "locale": "fr-FR",
          "name": "PPCM*"
        },
        {
          "locale": "he-IL",
          "name": "LCM"
        },
        {
          "locale": "hr-HR",
          "name": "LCM"
        },
        {
          "locale": "hu-HU",
          "name": "LKT"
        },
        {
          "locale": "id-ID",
          "name": "LCM"
        },
        {
          "locale": "it-IT",
          "name": "LCM"
        },
        {
          "locale": "ja-JP",
          "name": "LCM"
        },
        {
          "locale": "ko-KR",
          "name": "LCM"
        },
        {
          "locale": "lt-LT",
          "name": "LCM"
        },
        {
          "locale": "lv-LV",
          "name": "LCM"
        },
        {
          "locale": "nb-NO",
          "name": "LCM"
        },
        {
          "locale": "nl-NL",
          "name": "KGV"
        },
        {
          "locale": "pl-PL",
          "name": "NAJMN.WSP.WIEL"
        },
        {
          "locale": "pt-BR",
          "name": "LCM"
        },
        {
          "locale": "pt-PT",
          "name": "MMC"
        },
        {
          "locale": "ro-RO",
          "name": "LCM"
        },
        {
          "locale": "ru-RU",
          "name": "НОК"
        },
        {
          "locale": "sk-SK",
          "name": "LCM"
        },
        {
          "locale": "sl-SI",
          "name": "LCM"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "LCM"
        },
        {
          "locale": "sv-SE",
          "name": "MGM"
        },
        {
          "locale": "th-TH",
          "name": "LCM"
        },
        {
          "locale": "tr-TR",
          "name": "OKEK işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "LCM"
        },
        {
          "locale": "vi-VN",
          "name": "LCM"
        },
        {
          "locale": "zh-CN",
          "name": "LCM"
        },
        {
          "locale": "zh-HK",
          "name": "LCM"
        },
        {
          "locale": "zh-TW",
          "name": "LCM"
        }
      ],
      "signature": {
        "display": "LCM(number1, [number2], ...)",
        "parameters": [
          {
            "description": null,
            "name": "number1",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "number2",
            "optional": true,
            "repeats": true
          }
        ],
        "trailing_repeats": true
      },
      "surface_name": "LCM",
      "version_marker": null,
      "xlcall": {
        "code": "475",
        "symbol": "xlfLcm"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/lcm-function-7152b67a-8bb5-4075-ae5c-06ede5563c94"
  },
  "try_it": {
    "formula": "=LCM(2.9, 3)"
  },
  "url": "https://handbook.dnacalc.com/functions/LCM.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "LCM(9007199254740992, 2) returned 9007199254740992 (0x4340000000000000). Inputs were supplied through cells using Value2. These are controls from this environment, not a same-input comparison with another build.",
      "excel_build": "16.0 build 20430",
      "observations": [
        {
          "call": "LCM(9007199254740992, 2)",
          "excel": {
            "bits": "0x4340000000000000",
            "display": "9007199254740992",
            "kind": "number"
          },
          "input_route": "cell-value2",
          "inputs": [
            {
              "name": "number1",
              "value": {
                "bits": "0x4340000000000000",
                "display": "9007199254740992",
                "kind": "number"
              }
            },
            {
              "name": "number2",
              "value": {
                "bits": "0x4000000000000000",
                "display": "2",
                "kind": "number"
              }
            }
          ],
          "recorded_in": "Excel 16.0 build 20430, Windows 64-bit, CPU not recorded in this capture"
        }
      ],
      "platform": "Windows 64-bit, CPU not recorded in this capture",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-GCD-001.json"
      ]
    },
    {
      "behaviour": "7,967 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.LCM.json"
      ]
    }
  ]
}