Created
December 24, 2012 21:01
-
-
Save dvberkel/4370687 to your computer and use it in GitHub Desktop.
Magma code to tabulate a corollary to Bertrand's postulate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return list of pairs of [1 .. 2*n] where every pair sums to a prime. | |
function prime_pairs(n) | |
if n eq 0 then | |
return []; | |
else | |
N := 2 * n; | |
p := NextPrime(N); | |
m := p - N; | |
result := [ <m + i, N - i> : i in [0 .. ((N - m) div 2)]]; | |
return prime_pairs(m div 2) cat result; | |
end if; | |
end function; | |
prime_pairs(1); | |
prime_pairs(2); | |
prime_pairs(3); | |
prime_pairs(4); | |
prime_pairs(5); | |
prime_pairs(6); | |
prime_pairs(7); | |
prime_pairs(8); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment