Least common multiple
Enter a list of whole numbers and get their least common multiple, the smallest positive number all of them divide into: 12, 18 and 24 give 72. Minus signs are ignored and one list can hold up to 32 numbers. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Numbers
- 12, 18, 24
- Quantity
- 3
- Lcm
- 72
The least common multiple of a list of integers is the smallest positive integer that every listed value divides without remainder. Students use LCM to add and subtract fractions with unlike denominators; engineers use it to align repeating cycles, gear teeth, and sampling windows; programmers use it to size tiles, buffers, and repeating job periods so several loops meet again. Negative inputs are reduced to absolute values because divisibility ignores sign. Zero is rejected: no positive integer is divisible by zero.
What the least common multiple is and why it is unique
The least common multiple (LCM) of integers a1, a2, through ak is the smallest positive integer m such that each ai divides m. Equivalently, m is the smallest positive common multiple of the whole list. For two values the identity lcm(a, b) equals the absolute value of a times b divided by gcd(a, b) follows from unique factorization: after cancelling the shared prime powers counted by the gcd, the product reconstructs the maximum exponent of every prime.
That identity extends to longer lists by associativity: lcm(a, b, c) equals lcm of lcm(a, b) with c. A single-element list is allowed; its LCM is the absolute value of that integer, which is the smallest positive multiple of itself. Two coprime integers have LCM equal to the product of their absolute values, which is why coprime periods coincide only at that product.
Signs do not change the LCM: negative twelve and eighteen have the same LCM as twelve and eighteen, because a positive integer is divisible by negative twelve exactly when it is divisible by twelve. Zero is different. The statement that m is divisible by zero would require zero to divide m, which holds only for m equal to zero, and zero is not positive.
This calculator therefore rejects any list that contains zero instead of returning a conventional zero that would contradict the positive-integer definition. The result is unique: there is at most one smallest positive common multiple, and for a finite list of non-zero integers it always exists.
Where an LCM calculator earns its keep
Classrooms and tutoring platforms call an LCM calculator so learners can check common denominators and cycle problems without factoring by hand. Exam generators need a deterministic oracle that rejects empty lists and non-integers instead of inventing a default that a buggy grader might treat as success. Operations and scheduling tools take the LCM of several period lengths — shift rotations, maintenance windows, polling intervals — to find the first time all clocks align.
Digital design and game tools use LCM to choose a sprite-sheet stride or a tile size that fits several animation frame counts. Signal-processing notebooks take LCM of sample counts or hop sizes when resampling loops must close on an integer boundary. Prefer this capability when the search intent is LCM alone, not a combined GCD-and-LCM dump and not a prime-factorization explorer.
What you can do with it
Common denominators in fraction work
Find the least common multiple of several denominators so addition, subtraction, and comparison of fractions share one exact bottom term.
Aligning repeating schedules
Take the LCM of shift lengths, maintenance cycles, or polling periods to compute the first instant when every cycle lands together.
Tiling, buffers, and animation strides
Choose a buffer, tile, or sprite-sheet width that is a multiple of every frame count or block size in a pipeline.
FAQ
How does the LCM calculator compute the least common multiple?
It folds Euclidean gcd across the list and applies lcm(a, b) = |a / gcd(a, b) * b| in BigInt arithmetic, then returns the positive result as lcm.
Are negative integers allowed?
Yes. Signs are ignored because a positive integer is divisible by −n exactly when it is divisible by n. The returned lcm is always positive.
Why is zero not allowed in the list?
Because no positive number can be divided by zero, so a list containing zero has no least common multiple in the usual sense. Instead of returning a conventional 0, the calculator asks you to remove it.
How does the LCM help me add fractions?
The LCM of the denominators is the smallest common denominator. For 1/3 plus 1/4 it is 12, so you rewrite them as 4/12 and 3/12 and add the tops to get 7/12.
What is the LCM of two numbers with no common factor?
It is simply their product. 2 and 5 share no factor, so their LCM is 10, which is also why a task every 2 days and one every 5 days only fall on the same day every 10 days.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/math/lcm \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"numbers":[12,18,24]}'const res = await fetch("https://api.kit.forhosting.com/math/lcm", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"numbers": [
12,
18,
24
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/lcm",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"numbers": [
12,
18,
24
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/lcm", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"numbers":[12,18,24]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"numbers":[12,18,24]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/lcm", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"numbers": [
12,
18,
24
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.lcm",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_items | 32 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This calculator accepts a JSON list of integers, rejects an empty list and any non-integer element, and returns that unique positive LCM. Successful API calls cost $0.002; invalid input is not billed.
Input contract, Euclidean fold, and error behaviour
Each magnitude must be a JavaScript safe integer; if the folded LCM itself would exceed MAX_SAFE_INTEGER the task fails rather than rounding to a nearby float, which would silently lie. On success the body echoes the parsed numbers, reports count, and returns lcm as the positive integer result. Example: numbers twelve, eighteen, twenty-four yields lcm seventy-two, because seventy-two is divisible by each of them and no smaller positive integer is. Example: numbers seven yields seven. Example: numbers negative four, six, eight yields twenty-four. Failed validation is not billed. POST a JSON object with one required field, numbers: a non-empty array of integers. Each element must be a whole number — a JSON integer, an integer-valued Number, a BigInt, or a digit string with an optional sign. Empty arrays fail with invalid_input because there is no well-defined LCM of no arguments in this API. Non-integers such as decimals like 12.5, booleans, objects, nulls, and non-numeric strings also fail, naming the offending element so you can fix the payload. The list may hold at most thirty-two values so a single Worker request stays cheap. The published API price for a successful call is $0.002.
Where an LCM calculator earns its keep
Keep the list non-empty, keep every element an integer, treat invalid_input as a client fix rather than a retry, and you get a reproducible least common multiple for LMS plugins, notebooks, and edge workers without standing up a computer-algebra system.
Technical questions
What happens if the numbers list is empty?
The task fails with invalid_input. This API requires at least one integer; there is no LCM of an empty list.
Why is zero rejected?
No positive integer is divisible by 0. Returning 0 would contradict the smallest-positive-integer definition, so zero is invalid_input.
What does the LCM calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.