I have been writing some c code to investigate the properties of prime numbers. Currently I have a function getPrimes(int primemax) which dynamically allocates memory for an array of the primes, so that primes[0]=2 , primes[1]=3 .... This has been working well, but I am going to need a more permanent and scalable way to store them as primemax grows large. I am not opposed to using some service (if such a service exists) or to writing my own code to possibly store them as a csv list.

My future algorithm will constantly be needing to find primes[bignumber] where bignumber is the index of the primes array. The actual prime stored in that index will be even larger.

Any thoughts appreciated. Thanks.