isPrime

I have been having trouble with prim numbers as well, but in my assignment I have to use the isPrime function to find the prime numbers from 2 to 1000000. I also have to use power2 because we arent allowed to use the pow function since its all integers, to find the mersenne primes which are, when raising a prime number to 2 then subtracting 1 = a prime number. If anyone could help me out on this it would be appreciated because I am struggling, thank you
I also just have to print all of the mersenne primes on my assignment, not asking people to enter in a number, just printing them all
Try to rephrase that in a clear question.
well first I am having trouble with the isPrime function to find and print all the prime numers from 2 to 1000000. thats the first part I am having trouble with
my ending assignment should just print out all the mersenne primes, but I have to use the function.
isPrime returns true when the passed number is a prime and false otherwise.
So just keep calling it in a loop for each number. I don't see the problem.
well give me an example please
what loop?
for (int i=2;i<=1000000;i++)if (isPrime(i))cout << i << " is prime.\n";
it says isPrime must return a value, what is that?
Topic archived. No new replies allowed.