ForHosting KIT · Math

Coprime checker

8 and 15 are coprime: their greatest common divisor is 1. Enter any two integers, negatives and zero included, and get the exact common divisor plus a clear yes or no on whether they are relatively prime. 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
First integer
8
Second integer
15
You get
Gcd
1

The coprime checker answers a basic number-theory question: do two integers share only one as a common positive divisor? The engine uses the classical Euclidean algorithm on absolute values, so the result is exact, deterministic, and free of floating-point drift. It never calls the network, never samples randomness, and never depends on the clock.

What coprime means and what you see

Two integers are coprime, or relatively prime, when their only positive common divisor is one. Equivalently, gcd of a and b equals one. Classic examples include eight and fifteen, whose divisors do not overlap beyond one, and fourteen and twenty-one, which share seven.

The special case a equals zero and b equals zero is rejected because gcd of zero and zero is undefined in this setting and coprimality cannot be decided. By contrast, zero and five is valid: the gcd is five and coprime is false. Negative inputs are allowed and are reduced via absolute values, matching the usual mathematical convention that gcd is non-negative.

If you need prime factors of a single integer rather than a pairwise gcd test, use a factorization tool; this page answers only the two-integer coprimality and gcd question.

How the inputs are read and how Euclidean gcd stays exact

Optional leading plus or minus signs are allowed; embedded spaces, hex prefixes, and exponential notation are rejected so a bad cell does not become a wrong flag. The engine stays inside JavaScript safe integers, which is more than enough for classroom problems, programming contests, and most applied checks on modular inverses or simplified ratios. Internally the absolute values are fed to the Euclidean algorithm: repeatedly replace the larger remainder pair until the remainder is zero, then the last non-zero remainder is the gcd.

That procedure is centuries old, needs only a handful of divisions for ordinary inputs, and never approximates. There is no floating-point step that could round a near-integer into a false coprime claim.

Where coprimality checks fit in study, crypto intuition, and code

Students meet coprime pairs when reducing fractions, when proving that Euler’s totient counts integers up to n that are coprime to n, and when a modular inverse exists precisely because the coefficient and the modulus are coprime. Teachers can generate answer keys for worksheets without trusting opaque calculator apps that hide the gcd.

Developers use the same contract to validate that two seed values are relatively prime before building a linear congruential generator, to pre-check RSA-style e and phi relationships in educational demos, or to gate a fraction-normalization step in data pipelines. Contest practice often needs a fast offline source of gcd and coprime answers so solutions can be checked without downloading tables. Pair it with prime factorization when you need the prime powers behind a single integer, and with an nth-prime tool when you need ranks rather than pairwise divisors.

Fraction reduction and lowest terms

Check whether numerator and denominator are already coprime before simplifying a ratio, or confirm a student’s reduced fraction has gcd one.

Modular inverse preconditions

Verify that a coefficient and a modulus are coprime so an inverse is guaranteed to exist in modular arithmetic demos and contest solutions.

What does the coprime checker cost?

It is free in your browser on this page.

Are negative integers allowed?

Yes. Signs are accepted and the gcd is computed on absolute values, so gcd is always a non-negative integer and coprime depends only on that value.

Is the algorithm randomized?

No. It uses the deterministic Euclidean algorithm. The same pair a,b always yields the same gcd and the same coprime flag.

How is this different from prime factorization?

Factorization splits one integer into prime powers. This tool takes two integers, returns their gcd, and sets coprime true exactly when that gcd equals one.

What happens if both numbers are zero?

The check is refused, because the greatest common divisor of zero and zero is undefined and coprimality cannot be decided. If only one of the two numbers is zero, the check works normally and returns a divisor.

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/numth/coprime-checker

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/numth/coprime-checker \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":8,"b":15}'
{
  "a": 8,
  "b": 15
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.coprime_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.

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.

Supply integers a and b and the tool returns both the greatest common divisor and a boolean coprime flag that is true exactly when that gcd equals one. Use it free in the browser for homework, RSA key intuition, fraction reduction checks, and contest prep, or call the API at $0.002 per successful request when you automate validation pipelines, grading scripts, or teaching demos that need reproducible coprimality answers.

What coprime means and what the response contains

This checker returns the original integers a and b as parsed, the positive gcd, and a boolean coprime field that is true if and only if that gcd is exactly one. The contract is strict: missing fields, non-integers, fractions, scientific notation, and values outside the safe integer range fail with invalid_input and a clear message.

How the inputs are read and how Euclidean gcd stays exact

The preferred fields are a and b as JSON integers, but decimal strings and the aliases x or m for the first value and y or n for the second are accepted so forms, spreadsheets, and query strings can reuse one contract.

Where coprimality checks fit in study, crypto intuition, and code

On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.

Deterministic test fixtures

Generate reproducible coprime and non-coprime pairs for unit tests, property checks, and CI assertions without embedding static tables.

What happens if both a and b are zero?

The request fails with invalid_input. gcd(0,0) is undefined here and coprimality cannot be decided when both inputs are zero.

Read the full KIT documentation →