### Primes Between Consecutive Cubes: How many primes are there between n3 and (n+1)3?

Legendre's conjecture states that, for each positive integer n, there is at least one prime between n2 and (n+1)2. On this page, we will investigate a related question: How many primes are there between n3 and (n+1)3?

Here are two hypotheses – and both of them appear to be true:
(A) For each integer n > 0, there are at least four primes between n3 and (n+1)3.
(B) For each integer n > 0, there are at least 2n + 1 primes between n3 and (n+1)3.

Note that if the above statement (B) is true, then statement (A) is also true. Indeed, for n = 1 both statements are easy to check – and both are true, while for n ≥ 2 statement (A) follows from (B) because 2n + 1 > 4 for every n ≥ 2. Statement (B) is suggested by these observations:
(1) For integer m > 1051, each interval [m3/2, (m+1)3/2] contains a prime (generalized Legendre conjecture, case 3/2).
(2) For positive integers m and n, each interval [n3, (n+1)3] contains precisely 2n+1 intervals [m3/2, (m+1)3/2], for example:

• the interval [13, 23] contains three intervals [13/2, 23/2], [23/2, 33/2], [33/2, 43/2];
• the interval [23, 33] contains five intervals [43/2, 53/2], [53/2, 63/2], [63/2, 73/2], [73/2, 83/2], [83/2, 93/2];
`...`
• the interval [333, 343] contains 67 intervals [10893/2, 10903/2],`...` [11553/2, 11563/2]; and so on.

Combining (1) and (2), we see that, since 10513/2 < 10893/2 = 333, statement (B) is true for n ≥ 33 provided that (1) is true. But we already tested statement (1) and, based on the knowledge of maximum prime gaps, (1) holds true for large numbers (from m = 1052 and up to 18-digit primes). However, when m and n are small, statement (1) does not help us establish (B). Therefore, now it is of particular interest to test statement (B) directly for small n. The table below presents a computational check of statement (B) for a range of consecutive small cubes – and our computational experiment shows that (B) is apparently true. There are at least 2n + 1 primes between consecutive cubes n3 and (n+1)3. (We have to remember, though, that a computational check alone is not a proof.)

```      n      n3   <    primes    <  (n+1)3  How many primes?    OK/fail
Expected:  Actual:

largeGaps = new Array(
23, 89, 139, 199, 113, 1831, 523, 887, 1129, 1669, 2477, 2971, 4297, 5591, 1327, 9551, 30593, 19333, 16141,
15683, 81463, 28229, 31907, 19609, 35617, 82073, 44293, 43331, 34061, 89689, 162143, 134513, 173359, 31397,
404597, 212701, 188029, 542603, 265621, 461717, 155921, 544279, 404851, 927869, 1100977, 360653, 604073,
396733, 1444309, 1388483, 1098847, 2238823, 1468277, 370261, 492113
)

largeGaps.sort(numericSortOrder);
function numericSortOrder(x,y) {return x-y;}

// all results
function showVerification(start,stop) {
var nc1, nc2, actPrimes, minPrimes, p1, p2, p3;
start=Math.floor(start);
if (stop==null) stop = start+2; // use start+2 when checking largeGaps

for (var n=start; n<=stop; n++) {
nc1 = n*n*n;
nc2 = (n+1)*(n+1)*(n+1);

minPrimes = 2*n + 1;

actPrimes = 0;
p1 = nextPrime(nc1);
p2 = p1;
p3 = p1;
if (p1 < nc2) actPrimes = 1;
// we have checked it's at least one!

while ((p3 = nextPrime(p2)) < nc2) {
actPrimes++;
p2 = p3;
}

document.writeln ( format7(n)
+ ' '+format7(nc1)+' <b>'+format7(p1)+'...'+format7(p2)+'</b> '+format7(nc2)
+'  '+format7(minPrimes)+' '+format7(actPrimes)+'    '
+ (minPrimes > actPrimes ? ' FAILED':'  OK   ')
)
}
}

// Verification for a specific interval
showVerification(start=1, stop=80)

// Verification by looping through largeGaps
// (depends on a reliable list of large prime gaps)
/*
document.writeln ('\nVerification for all gaps in the largeGaps array')
for (var i=0; i<largeGaps.length; i++) {
var gprime = largeGaps[i];
document.writeln ('Large gap after the prime '+gprime)
showVerification( Math.floor(Math.sqrt(gprime)) );
}
*/
```