ForHosting KIT · Math

Wieferich prime checker

1093 is a Wieferich prime: 2 raised to 1092 leaves remainder 1 when divided by 1093², which is 1194649. Enter a prime to see that remainder and whether the rare condition holds. 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
Power (W)
1,093
You get
P squared
1194649
Remainder
1
Expression
2^{1092} ≡ 1 (mod 1194649)

A Wieferich prime is a prime number p for which two raised to the power p minus one leaves remainder one when divided by p squared. That congruence strengthens the usual Fermat little theorem statement that two to the p minus one is one modulo p itself, and it appears in the study of Fermat’s last theorem for the first case, lifting-the-exponent lemmas, and odd perfect number constraints. Only two such primes are known—one thousand ninety-three and three thousand five hundred eleven—so most everyday primes fail the test. This checker accepts a single prime p, verifies primality, computes the exact modular power with deterministic BigInt arithmetic, and returns whether the remainder is one together with p squared and a short congruence string.

What a Wieferich prime is and why the modulus is p squared

Fermat’s little theorem says that if p is prime and does not divide the base a, then a to the p minus one is congruent to one modulo p. For a equals two this is simply two to the p minus one congruent to one modulo p for every odd prime p. A Wieferich prime asks for the same congruence one modulus higher: two to the p minus one must be congruent to one modulo p squared, not merely modulo p.

Equivalently, the order of two in the multiplicative group of units modulo p squared divides p minus one in a way that forces the Fermat quotient of two base p to vanish. That extra p factor in the modulus makes the condition extremely rare. Exhaustive computer searches have checked primes far beyond any classroom example, and the only known solutions remain p equals one thousand ninety-three and p equals three thousand five hundred eleven.

The prime two fails: two to the first power is two, and two modulo four is two, not one. Ordinary primes such as three, five, seven, and eleven produce remainders other than one when two to the p minus one is reduced modulo p squared.

Where a Wieferich prime checker earns its keep

Number-theory courses and contest training platforms use a Wieferich prime checker so learners can verify textbook claims about the two known examples without implementing modular exponentiation by hand and without confusing the modulus p with p squared. Research notebooks and recreational math scripts call the same contract when scanning candidate primes or validating offline tables against an independent oracle. Content sites that rank for Wieferich prime checker or related Fermat quotient queries benefit from a live tool whose free path matches the paid automation path byte for byte.

Engineering teams that teach or demo cryptographic number theory can show how a congruence that looks like Fermat’s little theorem becomes vanishingly rare once the modulus is squared, reinforcing why naive modular assumptions need careful statement. Prefer this tool when the question is strictly whether a given prime satisfies two to the p minus one congruent to one modulo p squared—not when you need a search over all primes in a range, a full factorization service, or certificates for multi-thousand-bit integers.

Independent oracle for research notebooks

Validate offline tables or scripted scans of candidate primes against a deterministic modular-power implementation.

What is a Wieferich prime?

A prime p such that 2^{p−1} ≡ 1 (mod p²). Only 1093 and 3511 are known. The check is stricter than Fermat’s little theorem, which only requires congruence modulo p.

Is 1093 a Wieferich prime?

Yes. 1093 squared is 1194649, and 2 raised to 1092 leaves remainder 1 when divided by that square, which is exactly the Wieferich condition. It is one of only two known examples.

How many Wieferich primes are known?

Only two: 1093 and 3511. Computer searches have checked primes far beyond any classroom example without finding a third, so almost every prime you test will fail.

Is 2 a Wieferich prime?

No. For the prime 2, the power is 2 to the first, which is 2, and 2 divided by 4 leaves remainder 2, not 1. The condition fails.

How does a Wieferich prime differ from Fermat's little theorem?

Fermat's little theorem says 2 to the power p minus 1 leaves remainder 1 when divided by p, for any odd prime. A Wieferich prime demands that remainder 1 on division by p squared.

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/wieferich-prime

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/wieferich-prime \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"p":1093}'
{
  "p": 1093
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.wieferich_prime",
  "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.

Composite input is rejected with invalid_input rather than a false negative, so homework scripts and research notebooks never treat a composite as a non-Wieferich prime by accident.

What a Wieferich prime is and why the modulus is p squared

This endpoint encodes exactly that definition: it never softens the modulus back to p, never substitutes a probabilistic witness, and never returns is_wieferich true unless the full modular power equals one.

Input contract, response fields, and error behaviour

Critically, p must be prime. POST a JSON body with the required integer field p (aliases prime and n). The value may arrive as a JSON number or as a decimal digit string; it must be a whole integer at least two and at most the JavaScript safe-integer ceiling. Fractions, booleans, empty strings, and missing fields fail with invalid_input before any exponentiation runs. On success the body includes p echoed as a number; p_squared as the exact decimal string of p times p; remainder as the exact decimal string of two to the p minus one modulo p squared; is_wieferich as a boolean that is true only when remainder equals one; and expression, a human-readable congruence such as two to the one thousand ninety-two congruent to one modulo one million one hundred ninety-four thousand six hundred forty-nine.

Where a Wieferich prime checker earns its keep

Keep p prime and within the published safe range, treat invalid_input as a client fix, and pin the remainder string in tests so future refactors cannot silently change the modular result.

Classroom checks of the two known examples

Let students submit p equals 1093 or 3511 and confirm is_wieferich is true, then contrast with ordinary primes such as 3, 5, or 7.

SEO landing and free browser widget

Offer a Wieferich prime checker page whose free path matches the API remainder and flag for the same prime p.

What input does the checker accept?

A single prime integer p ≥ 2 (field p, aliases prime or n), as a JSON number or digit string within the safe integer range. Non-primes and malformed values fail with invalid_input.

What happens if p is not prime?

The task fails with invalid_input. Wieferich primes are defined only for primes; composites are rejected rather than returned as is_wieferich false.

Is 2 a Wieferich prime?

No. 2^{1} = 2 and 2 mod 4 equals 2, not 1, so is_wieferich is false for p equals 2.

What does the Wieferich prime checker cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →