Try to calc the first prim numbers up to a limit.
We use the the sieve of Eratosthenes. It is a simple, ancient algorithm for finding all prime numbers up to any given limit.
It does so by iteratively marking as composite (i.e., not prime) the multiples of each prime, starting with the multiples of 2.
The sieve of Eratosthenes is one of the most efficient ways to find all of the smaller primes.
It is named after Eratosthenes of Cyrene, a Greek mathematician.
To find realy big primes, we build a Mersenne prim of the form 2 n -1.
Not all numbers are prim, so we check for a given n, if we have really a prim number, using Lucas-Lehmer test.