Is prime checker
Checks whether a whole number is prime and, if not, shows the smallest divisor that proves it: 97 comes back prime, with no divisor at all. Small factors show up at once and large primes are confirmed by a fixed, exact test. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
The is prime checker decides whether an integer n is prime and, when it is not, returns the smallest divisor that proves the number is composite. It combines classical trial division with a deterministic Miller–Rabin test so small factors surface immediately and large primes are confirmed without an exhaustive search of every candidate up to the square root. You send a single whole number greater than or equal to two and receive a clear prime flag, the original n, and either null or the least divisor—deterministic arithmetic with no random witnesses and no network lookup.
How trial division and Miller–Rabin work together
Trial division is the oldest primality technique: test whether successive candidates divide n, starting with two and three and continuing along a six-step wheel that only checks numbers of the form 6k±1. As soon as a divisor appears, the number is composite and that divisor is the smallest one—exactly what many teaching tools, coding problems, and data-quality checks need. When n is modest, completing the trial up to the integer square root is enough to prove primality as well, because every composite has a factor at most its square root.
For larger integers the checker first scouts for small factors with the same trial loop, then runs a deterministic Miller–Rabin suite with fixed bases that are known to decide primality correctly for every integer in the safe JavaScript range. If Miller–Rabin reports prime after no small factor was found, the result is prime.
Where to use an is-prime checker in real workflows
Educators and students use a reliable is prime checker to verify homework, generate counter-examples, and show why a number fails by displaying its least divisor instead of a bare false. Application developers call it when a product key, puzzle seed, or cryptographic toy parameter must be prime-shaped before further work, catching typos such as even values or obvious multiples without standing up a full computer-algebra system.
Data engineers gate numeric columns in imports: any claimed “prime identifier” that fails here is rejected early with a concrete factor for the audit log. Prefer this tool when the question is strictly “is n prime, and if not what is the smallest divisor?”—not when you need complete factorization, primality certificates for huge multi-thousand-bit integers, or probabilistic tests with custom witness lists.
What you can do with it
Homework and teaching demos
Show students whether a number is prime and immediately display the smallest divisor when it is composite, so the failure mode is concrete rather than abstract.
Validate prime-shaped configuration values
Reject even or obviously composite parameters in product keys, puzzle seeds, or toy crypto settings before they enter a longer pipeline.
Audit numeric columns that claim to be primes
Scan an import of purported prime identifiers, flag composites, and attach the least divisor to the audit trail for each failing row.
FAQ
What does it cost?
The same check also runs free in your browser on this page.
Which numbers are accepted?
Whole integers greater than or equal to 2, up to the published safe-integer maximum.
Is the Miller–Rabin test probabilistic here?
No. The bases are fixed and deterministic for every integer in the supported range, so the same n always produces the same result.
Does this fully factor n?
No. It only reports whether n is prime and, when composite, the single smallest divisor—not the complete list of prime factors.
Why does it show a divisor when the number is not prime?
The smallest divisor greater than 1 is the proof that the number is composite. Any even number above 2, for instance, comes back with 2, so you see exactly why it failed instead of a bare no.
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/numth/prime-checker \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":97}'const res = await fetch("https://api.kit.forhosting.com/numth/prime-checker", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 97
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/prime-checker",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 97
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/prime-checker", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":97}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":97}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/prime-checker", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 97
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.prime_checker",
"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.
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
What the checker returns and when it rejects input
Every successful call answers three related questions at once: is n prime, what value was tested, and—if the number is composite—what is the smallest positive divisor greater than one. The response is a small JSON object with a boolean prime flag, the integer n echoed back as a number, the smallest_divisor field (null for primes, a concrete integer for composites), and a method label that records whether the decision came primarily from trial division or from Miller–Rabin. Input that is missing, fractional, non-numeric, or strictly less than two is rejected with invalid_input before any arithmetic runs, so a floating value like 9.5 or a zero never produces a misleading primality claim. The same rules apply in the free browser path and on the API: one contract, one set of error messages, and the same structured result. That predictability matters when you wire the checker into a form, a CLI tool, or a batch pipeline that must stop on bad data rather than invent an answer. Use this endpoint whenever you need an auditable yes-or-no on primality plus an explanatory factor, not a probabilistic guess or a long factorization of every divisor.
How trial division and Miller–Rabin work together
If it reports composite, trial division continues from the previous bound until the least factor is recovered, so the API never says “composite” without also naming the smallest divisor.
Where to use an is-prime checker in real workflows
Because the capability is tier A, you can paste a number on this page and run the identical logic free in the browser; automate the same contract later at $0.002 per request when you wire POST-style tasks into scripts or SDKs. Keep n an integer of at least two within the published safe range, treat invalid_input as a client fix rather than a retry, and store the returned method field if you need to explain which algorithm path decided the case.
Technical questions
What is returned for a composite number?
prime is false and smallest_divisor is the least integer greater than 1 that divides n. For primes, smallest_divisor is null.