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?
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?
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?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.
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?
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.
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.
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.