ForHosting KIT · Math

Least common denominator calculator

Get the smallest denominator two fractions can share: for 12 and 18 it is 36, so 5/12 and 7/18 become 15/36 and 14/36 and add in one step. The greatest common divisor used, 6, is shown too. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
12
B
18
You get
Denominator a
12
Denominator b
18
Gcd
6
Lcd
36

Give it 12 and 18 and it answers 36, along with the greatest common divisor it used to get there. The computation is the classic least common multiple via the Euclidean algorithm: deterministic, exact, and free of floating-point error, because everything is done with integer arithmetic.

What a least common denominator actually is

Two fractions can only be added or compared directly when they share a denominator. Any common multiple of the two denominators works, but the least common denominator — the smallest one — keeps every subsequent number small and the arithmetic manageable. For denominators 12 and 18, the common multiples include 36, 72, 108 and every further multiple of 36; the least is 36, so 5/12 and 7/18 become 15/36 and 14/36, which you can add in one step.

Choosing a larger common multiple like 72 is not wrong, just wasteful: you end up reducing the final answer anyway.

How the computation works

The engine computes the greatest common divisor of the two denominators with the Euclidean algorithm — repeatedly replacing the larger number by the remainder of the division until the remainder is zero. That takes a number of steps proportional to the logarithm of the inputs, so even very large denominators resolve instantly. The least common denominator is then the first denominator divided by that GCD, multiplied by the second denominator; dividing before multiplying keeps intermediate values as small as possible and avoids unnecessary overflow.

Everything happens in integer arithmetic, never in floating point, so the answer is exact rather than approximately correct. Input is validated strictly before any arithmetic: each denominator must be a positive integer, and zero, negatives, fractions, strings that are not numeric and missing fields are all rejected with a clear invalid-input error that is never charged.

Where it fits in real work

Anything that manipulates fractions programmatically needs this primitive sooner or later: educational software that generates and grades fraction exercises, recipe and nutrition tools that scale quantities expressed as fractions, engineering notebooks that keep exact rational values instead of decimal approximations, and scheduling or music-theory code that aligns cycles of different lengths, since aligning two cycles is the same least-common-multiple problem in disguise. Calls are stateless and nothing is stored: the denominators arrive, the answer leaves, and no record of your inputs is kept.

Grade fraction homework

An education app rewrites both answers over the LCD before checking whether a student's sum matches the expected fraction.

Scale a recipe exactly

A cooking tool combines 3/4 cup and 2/3 cup measures by converting both to twelfths without ever touching floating-point arithmetic.

Align two repeating cycles

A scheduler finds when a 12-day task and an 18-day task next fall on the same day — the same LCM the LCD is built from.

What does it cost?

The same calculator is free to use in your browser on this page.

What input does it expect?

Two fields, a and b, each the denominator of one fraction. Both must be positive integers.

What counts as invalid input?

Zero, negative numbers, non-integer numbers, non-numeric strings and missing fields.

Is the result exact?

Yes. Everything is computed with integer arithmetic using the Euclidean algorithm, so there is no floating-point rounding anywhere in the result.

What if the denominators are huge?

The algorithm itself handles very large integers instantly.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/common-denominator

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/common-denominator \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":12,"b":18}'
{
  "a": 12,
  "b": 18
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.common_denominator",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

The least common denominator API takes the denominators of two fractions and returns the smallest positive integer that both divide evenly — the number you need before you can add, subtract or compare those fractions. It runs on our global edge, and the very same code runs free in your browser on this page, so you only pay when you automate the call.

What a least common denominator actually is

The endpoint returns that smallest value directly, so the caller never has to enumerate multiples or reduce an inflated result. It also returns the greatest common divisor of the two denominators, because the two quantities are two views of the same relationship: the LCD is the product of the denominators divided by their GCD, and having both numbers on hand makes it trivial to rewrite each original fraction over the new denominator without a second call.

How the computation works

If the true least common denominator would exceed the safe integer range of the platform, the endpoint says so explicitly instead of silently returning a rounded value, because a rounded denominator is worse than no answer at all.

Where it fits in real work

Through the API the call costs $0.002 per item, which makes it cheap enough to put inside a hot loop that processes thousands of fraction pairs, while occasional manual use stays free forever in the browser.

Do you store my denominators?

No. The call is stateless: the input is processed and discarded, and only the result is returned.

Read the full KIT documentation →