Twin Prime Calculator
Check whether a number has another prime exactly two away.
What it does
Twin primes are pairs of prime numbers separated by a gap of two. The first pairs are 3 and 5, 5 and 7, and 11 and 13. A number may be the smaller or the larger member of a pair.
This tool tests the number you enter and the integers two away in each direction. It reports whether a pair exists and names the partner, so a single query answers both the upward and downward case.
Primality is checked by trial division up to the square root, skipping even candidates after two. That is fast enough for the range the tool accepts and gives an exact answer rather than a probability.
The twin prime conjecture says there are infinitely many such pairs. It remains unproven, so the tool only checks the number you supply. It makes no claim about how common pairs are at large sizes.
How to use
- Enter a whole number of at least 2.
- Read the result in the main area.
- Check the partner shown underneath.
- Try a number that is the larger member of a pair.
- Try a composite number to see a negative result.
- Compare with a prime checker for the single number.
Formula
- n
- The whole number being tested.
- n+2, n-2
- The two possible partners two away.
- prime
- A number with no positive divisor other than 1 and itself.
A number can belong to two pairs at once when it sits in the middle of a triple such as 5, which pairs with both 3 and 7. The tool reports the upward partner first when both exist. The pair 2 and 3 differs by one rather than two and is not treated as a twin pair here, which matches the usual convention.
Worked example
Example: testing 17
The number 17 as input.
- Check 17 itself: it is prime.
- Check 19, two away upward: it is prime.
- So 17 and 19 form a twin prime pair.
- The partner reported is 19.
- Checking downward, 15 is not prime.
- Tool shows Twin prime with the pair 17 and 19.
Reference table
| Smaller member | Larger member | Gap |
|---|---|---|
| 3 | 5 | 2 |
| 5 | 7 | 2 |
| 11 | 13 | 2 |
| 17 | 19 | 2 |
| 29 | 31 | 2 |
Limits
- Checks one number at a time, not a whole range.
- Inputs are capped at one billion.
- The conjecture about infinitely many pairs is unproven.
- Pairs where both members are large may still be found by this exact test.
Common mistakes
- Assuming any two consecutive primes are twin primes.
- Counting 2 and 3 as a twin pair.
- Forgetting that a middle number can belong to two pairs.
- Testing only the number upward by two.
- Confusing the gap with the difference of one.
Try it yourself
Quick checks. Answers sit tucked under each question.
Is 17 a twin prime?
Yes. 17 and 19 are both prime and differ by 2.
Is 89 part of a twin pair?
No. 87 and 91 are both composite.
Which pair comes after 11 and 13?
17 and 19.
Questions
What is a twin prime?
A prime with another prime exactly two away.
Are 2 and 3 twin primes?
Usually not, because they differ by one.
Can one number belong to two pairs?
Yes, when it sits between two primes two apart, as 5 does.
Are there infinitely many twin primes?
It is conjectured but not proven.
How does the tool test primality?
By trial division up to the square root.
What is the largest input accepted?
One billion.