Returns the number minimum prime gap.
[gap,p] = number_minimumprimegap ( n )
a 1-by-1 matrix of floating point integers, the largest prime to consider
a m-by-1 matrix of floating point integers, the difference of prime numbers
a m-by-1 matrix of floating point integers, the corresponding prime number
Returns the minimum prime gap function. The integer gap(k) = q-p(k), where q is the prime just greater than p(k). The integer p(k) is the smallest prime number so that the differnce of primes is gap(k).
[gap,p] = number_minimumprimegap ( 1500 ) expected_gap = [1 2 4 6 8 14 18 20 22 34]' expected_p = [2 3 7 23 89 113 523 887 1129 1327]' // Plot it stacksize("max"); scf(); n=1000000; [gap,p] = number_minimumprimegap ( n ); plot(gap,log(p)^2,"bo") plot(gap,gap,"r-") legend(["Empirical","Cramer-Shanks Conjecture"]);
http://mathworld.wolfram.com/PrimeGaps.html