Home › Math › GCD and LCM Calculator
GCD and LCM Calculator
Computes the greatest common divisor (highest common factor) and least common multiple of two or more integers with the Euclidean algorithm.
When to use
You need the GCD/HCF or LCM of a list of integers, e.g. to reduce fractions, find a common denominator or check whether numbers are coprime.
Do not use when: You need the prime factors themselves (use prime-factorization) or want to reduce a single fraction (use fraction-simplifier).
Formula
gcd(a, b) by the Euclidean algorithm (gcd(a, b) = gcd(b, a mod b)); lcm(a, b) = |a × b| / gcd(a, b); both are folded over the list: gcd(a, b, c) = gcd(gcd(a, b), c)
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
numbers | number_list | yes | Two or more integers, comma-separated (e.g. 12, 18, 24). Negative values are treated by their absolute value. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
gcd | integer | Greatest common divisor of all the numbers. | |
lcm | integer | Least common multiple of all the numbers. | |
coprime | boolean | true when the GCD is 1 (the numbers share no common factor). |
Example
12 and 18: {"numbers":[12,18]} → {"gcd":6,"lcm":36,"coprime":false}
4, 6 and 8: {"numbers":[4,6,8]} → {"gcd":2,"lcm":24,"coprime":false}
GET https://tttkmbb.com/api/v1/calculate/gcd-lcm?numbers=12%2C18
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/gcd-lcm(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/gcd-lcm · Markdown: https://tttkmbb.com/math/gcd-lcm.md · JSON definition: https://tttkmbb.com/math/gcd-lcm.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="gcd-lcm" - OpenAPI operationId:
calculate_gcd_lcm - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Greatest common divisor (reference)
- Wikipedia – Least common multiple (reference)
- Wolfram MathWorld – Greatest Common Divisor (reference)
FAQ
Is HCF the same as GCD?
Yes. Highest common factor (HCF), greatest common factor (GCF) and greatest common divisor (GCD) are the same quantity.
How large can the numbers be?
Any integers whose LCM stays below 2^53 (about 9 × 10^15); larger results cannot be represented exactly and return an error.
Related calculators
- Fraction Simplifier — Reduce a fraction by its GCD.
- Prime Factorization Calculator — See the prime factors behind the GCD and LCM.
- Ratio Calculator — Simplify a ratio by dividing by the GCD.