A high-precision prime number generator implemented in Haskell using the GMP (GNU Multiple Precision Arithmetic Library) for efficient prime computation.
This program finds and prints the next 10 prime numbers greater than a given integer.
Make sure GCC, GHC, and GMP are installed. To build and execute:
cd primes
gcc -c cbits/wrappers.c -o cbits/wrappers.o
ghc -O2 primes.hs cbits/wrappers.o -o primes
./primes <n>
Example:
cd primes
ghc -O2 primes.hs -o primes
./primes 100
Output:
101
103
107
109
113
127
131
137
139
149
mpz_nextprime
from GMP to find the next prime efficiently.Foreign Function Interface
).primes n
generates an infinite lazy list of primes greater than n
.take 10
part in the code to generate more primes.Abhrankan Chakrabarti