In computer science an array is indexed by an integer (int
). Unlike in mathematics, the computer science integer (int
) has a finite range defined by the length of it's fixed binary representation.
In most modern higher level languages the maximum value of an integer is 2^31 - 1
(2147483647
). I would like to create an array of sequential primes in a computer program I intend to write.
Example:
list[0] = 2;
list[1] = 3;
list[2] = 5;
list[3] = 7;
list[4] = 11; etc...
However, an array is indexed by an int
so I can only have 2,147,483,647
entries in the array. Because of this I would like to know what the largest prime I could place in the array of sequential prime entries.
What value would be placed in list[2147483647] = x;
What is the 2,147,483,647th prime number?
I'm not asking anyone in particular to calculate primes up to that iteration. I'm wondering how I might go about calculating it or find a place where it has already been precomputed. I know Wolfram has some precomputed primes but I couldn't find the correct prime tables.
EDIT: I ask this question because I come from a computing background, not mathematics and I have difficulty estimating the size of the 2,147,483,647th prime number. Rather then the exact value, a rough value will suffice. I just need to know how roughly large this prime is.
If represented in binary, roughly how may bits would the 2,147,483,647th prime contain?
If represented in decimal, roughly how may digits would the 2,147,483,647th prime contain?
Mathematica
, simplyPrime[2147483647]
yields50685770143
. For some interesting subtleties concerningPrime
I recommend reading this question : http://mathematica.stackexchange.com/questions/3327/what-is-so-special-about-prime – Artes Nov 19 '12 at 17:28Mathematica
. – Artes Nov 19 '12 at 17:55Prime and PrimePi use sparse caching and sieving. For large n, the Lagarias-Miller-Odlyzko algorithm for PrimePi is used, based on asymptotic estimates of the density of primes, and is inverted to give Prime.
– Artes Nov 20 '12 at 14:08int
size and the abstract study retains integers in their infinitely sized mathematical form. – recursion.ninja Mar 03 '13 at 22:36