Twin Prime Pair Checker
Check whether two nonnegative integers are prime and differ by two, accepting either order and limiting each candidate to 10¹² for trial division.
Description
Twin-prime pairs consist of two primes separated by two.
Twin-prime pairs consist of two primes separated by two. Both conditions matter: a difference of two alone does not identify a prime pair.1
The tool returns isTwinPair. The indexing and output conventions below determine how to read these values.
When to use Twin Prime Pair Checker
Use this for the following task: Check whether two nonnegative integers are prime and differ by two, accepting either order and limiting each candidate to 10¹² for trial division. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Twin Prime Pair Checker and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter first, second according to the field table, then run the tool.
- Read isTwinPair. A true flag means the candidate meets the stated property; false means it does not.
- If the flag is false, review the candidate and definition. A well-formed nonmember is different from a rejected input.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| first | First candidate (resource limit 10^12) | integer; minimum 0; maximum 1000000000000 | Required |
| second | Second candidate (resource limit 10^12) | integer; minimum 0; maximum 1000000000000 | Required |
Accept either order, check the difference and test both candidates by deterministic trial division within the declared bounds.
twin pair = prime(first) AND prime(second) AND |first−second|=2 The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| isTwinPair | Whether the candidates are twin primes | boolean |
{
"input": {
"first": 11,
"second": 13
},
"output": {
"isTwinPair": true
}
} Limitations and assumptions
Each candidate is at most 10¹². This checks a supplied pair and does not search for the next pair or estimate the frequency of twin primes.
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 Twin Prime Counting Function when you need its operation: Count twin-prime pairs whose smaller prime is at most n, testing the upper member even when it exceeds n; the sieve limit is capped at 1,000,000. Choose Cousin Prime Pair Checker for the complementary operation: Check whether two nonnegative integers are prime and differ by four, accepting either order and limiting each candidate to 10¹² for trial division.
Background reference: OEIS A001359.
References
-
OEIS A001359 — OEIS Foundation
Similar or alternative tools
- Twin Prime Counting Function
Count twin-prime pairs whose smaller prime is at most n, testing the upper member even when it exceeds n; the sieve limit is capped at 1,000,000.
- Cousin Prime Pair Checker
Check whether two nonnegative integers are prime and differ by four, accepting either order and limiting each candidate to 10¹² for trial division.