# Thread: Help: How to write a prime number greater than one billion

1. ## Help: How to write a prime number greater than one billion

My question is like I am clueless. And how I can write such as program that the first prime number is greater than one billion?

2. Basically, you are supposed to implement a program that finds primes greater than one billion? What ideas do you have? What do you know about primality testing?

3. As far as I know...Finding a prime needs to use the if-statement with a comparison operator == with the divisor of remainder. That's, if(something % something == 0) is not prime. So there is must be a remainder. I am just clueless as my level is not up to that or maybe I am just at the end of my wit.

4. You've got prime number testing code, right? You've posted it before. Why do you expect this to be in any way, shape, or form different?

5. I assume he has encountered the problem of integer overflows .

I think you used a simple int in your code? It's maximum value is around 2 billion. An unsigned int would increase it to 4 billion. You could also use a "long long int"; or an "unsigned long long int", which have way higher maximums. If these limits are still too low, you'll have to use a big integer class.

6. If I'm not mistaken long long is currently non-standard (but is going to make it in soon), so if the compiler supports it, go ahead.

7. long long is "merely" C99.