User Rating 0.0
Total Usage 0 times
Min: 2
Max: 100,000,000
Limit: 1 – 10,000
Presets:
Is this tool helpful?

Your feedback helps us improve.

About

Cousin primes are pairs of primes (p, p + 4) where both values are prime. They belong to the broader class of prime gaps studied in analytic number theory alongside twin primes (gap 2) and sexy primes (gap 6). The first Hardy - Littlewood conjecture predicts their density decreases as Cln2(n) where C 1.1970449 is a specific product over primes. Miscounting cousin primes or confusing them with twin or sexy primes leads to flawed assumptions in cryptographic gap analysis and prime distribution research.

This tool implements a segmented Sieve of Eratosthenes on a Web Worker thread. It computes all primes in your specified range, then filters pairs where p and p + 4 both appear in the sieve. Ranges up to 108 are supported. The tool approximates prime pair counts. It does not prove the infinitude of cousin primes. That remains an open conjecture.

cousin primes prime number generator prime pairs number theory sieve of eratosthenes math tool

Formulas

Two primes p and q form a cousin prime pair if and only if:

q = p + 4

where both p and q are prime. The conjectured density of cousin primes below N follows the first Hardy - Littlewood conjecture:

π4(N) 4 C2 Nln2(N) p > 3 p(p 2)(p 1)2

where C2 0.6601618 is the twin prime constant, and the product runs over odd primes p dividing the gap. The factor 4 corrects for the gap size relative to twin primes. The Sieve of Eratosthenes marks composites up to N. For each surviving prime p, if p + 4 also survives, the pair is recorded.

where p = a prime number in the sieve, q = the cousin candidate (p + 4), N = the upper bound of the search range, π4(N) = the cousin prime counting function, C2 = the twin prime constant.

Reference Data

Pair #Cousin Prime Pair (p, p + 4)SumProduct
1(3, 7)1021
2(7, 11)1877
3(13, 17)30221
4(37, 41)781517
5(43, 47)902021
6(67, 71)1384757
7(79, 83)1626557
8(97, 101)1989797
9(103, 107)21011021
10(109, 113)22212317
11(127, 131)25816637
12(163, 167)33027221
13(193, 197)39038021
14(223, 227)45050621
15(229, 233)46253357
16(277, 281)55877837
17(307, 311)61895477
18(313, 317)63099221
19(349, 353)702123197
20(397, 401)798159197
21(439, 443)882194477
22(457, 461)918210677
23(463, 467)930216221
24(487, 491)978239117
25(499, 503)1002250997

Frequently Asked Questions

Twin primes have a gap of 2 (e.g., 11, 13). Cousin primes have a gap of 4 (e.g., 7, 11). Sexy primes have a gap of 6 (e.g., 5, 11). All three are specific cases of prime gaps. A prime can belong to multiple categories: (7, 11) is a cousin pair, and (7, 13) is a sexy pair. The classification depends solely on the difference between the two primes in the pair.
This remains an open conjecture. The first Hardy - Littlewood conjecture predicts infinitely many cousin primes, and computational evidence strongly supports it. As of 2024, the largest known cousin prime pair has over 50,000 digits. However, no formal proof of infinitude exists. The Polymath8 project (following Zhang's 2013 breakthrough) proved bounded prime gaps exist but has not reached gap 4 specifically.
The number 6 is not prime (6 = 2 × 3), so (2, 6) fails the primality condition. The pair (3, 7) works because both 3 and 7 are prime and 7 − 3 = 4. Note that 3 is the only prime p where p + 4 is also prime and p itself is less than 5. For p = 5, p + 4 = 9 = 3 × 3 which is composite.
Yes. The prime 7 belongs to the twin pair (5, 7) and the cousin pair (7, 11). The prime 13 belongs to the twin pair (11, 13) and the cousin pair (13, 17). This overlap is common in dense prime regions. Primes below 100 frequently participate in multiple gap categories.
The upper bound is 100,000,000 (10⁸). The sieve uses a Uint8Array of size N, consuming approximately 100 MB of memory at the limit. Beyond this, browser tab memory limits become a risk. The sieve runs inside a Web Worker to prevent UI freezing. For ranges above 10⁷, expect computation times of 1-5 seconds depending on hardware.
Not directly. RSA and elliptic curve cryptography use large primes but do not require specific gap relationships. However, studying prime gap distributions (including cousin primes) informs the probabilistic models used to estimate the difficulty of factoring large semiprimes. Understanding how primes cluster helps assess the entropy of prime generation algorithms.
The only prime ending in 5 is 5 itself. Any other number ending in 5 is divisible by 5 and therefore composite. So a pair (p, p+4) where both end in 5 would require p to end in 5 and p+4 to end in 9. The number p+4 ending in 9 can be prime (e.g., 29, 59), but p ending in 5 and being prime means p = 5, and 5 + 4 = 9 which is composite. Therefore no such pair exists.