I have a problem with my primes generator. It generates primes and write each one into a file. When I use unsigned long int for all calculations, the biggest prime I got is 523763, then program falls. But it doesn't fall due to cpu or huge memory usage. My algorithm is as fast while counting huge primes as counting small numbers. I thought that my problem is caused by unsigned long int, so I decided to use GMP library (library for huge numbers). I wrote everything well, there are no bugs in my code. Unfortunately, now it stopps on 52817. How it's possible ??!! I changed all unsigned long ints into gmp class, so I don't know what to do.....