This problem struck me as a bit odd. I’m curious how you could represent a list of prime numbers in a database. I do not know of a single datatype that would be able to acuratly and consistently store a large amount of prime numbers. My concern is that when the prime numbers are starting to contain 1000s of digits, that it might be a bit difficult to reference form the database. Is there a way to represent a large set of primes in a DB? I’m quite sure that this has topic has been approached before.
One of the issues about this that makes it difficult is that prime numbers can not be broken down into factors. If they could this problem would be much easier.
If you really want to store primes as numbers and one of questions, stopping you is “prime numbers can not be broken down into factors”, there are another thing: store it in list of modulus of any number ordered by sequence.
Small example:
List is:
In real application is useful to split by modulus of 2^32 (32-bits integers), specially if prime numbers in processing application stored as byte arrays.
Storage in DB:
insert for example above (1647 is for example only):
prime_id value can be assigned from oracle sequence …
Get ID of next prime number to insert:
select prime number content with specified id: