Wilson Prime Checker

Check whether p is prime and (p−1)!+1 is divisible by p², using modular products with a 100,000-factor resource limit.

Description

Wilson primes satisfy a stronger factorial congruence than Wilson’s primality theorem.

Wilson primes satisfy a stronger factorial congruence than Wilson’s primality theorem. Only primes whose factorial residual is divisible by the square of the prime qualify.1

The tool returns isWilson. The indexing and output conventions below determine how to read these values.

When to use Wilson Prime Checker

Use this for the following task: Check whether p is prime and (p−1)!+1 is divisible by p², using modular products with a 100,000-factor resource limit. Use the input and output conventions below to reproduce the intended mathematical quantity.

How to use Wilson Prime Checker and understand its results

  1. Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
  2. Enter p according to the field table, then run the tool.
  3. Read isWilson. A true flag means the candidate meets the stated property; false means it does not.
  4. If the flag is false, review the candidate and definition. A well-formed nonmember is different from a rejected input.
Input fieldMeaningValue type and boundsRequirement
pCandidate prime (factorial resource limit 100000)integer; minimum 1; maximum 100000Required

First test primality. For a prime, multiply factorial factors with BigInt and reduce modulo p² after each multiplication; test the final remainder.

Wilson prime: prime(p) AND ((p−1)!+1) mod p² = 0

The symbols and boundary conditions refer to the supplied fields and the implementation described above.

Output fieldMeaningValue type
isWilsonWhether p is a Wilson primeboolean
json
{
  "input": {
    "p": 13
  },
  "output": {
    "isWilson": true
  }
}

Limitations and assumptions

Composite inputs produce false rather than an input error. The candidate is capped at 100000 because the factorial computation requires a linear number of modular products.

Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.

Alternative or Complementary methods

Choose Wieferich Prime Checker when you need its operation: Check whether p is prime and 2^(p−1)≡1 (mod p²) with exact modular arithmetic; primality testing is limited to p≤10¹². Choose Prime Counting by the Sieve of Eratosthenes for the complementary operation: Count primes at most n exactly with the sieve of Eratosthenes, excluding zero and one and limiting n to 1,000,000.

Background reference: OEIS A007540.

References

  1. OEIS A007540 — OEIS Foundation

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies