d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C++ Primes > Topic
Add Reply New Topic New Poll
Member
Posts: 3,523
Joined: Sep 10 2011
Gold: 1,585.00
Oct 9 2015 12:13pm
Need a little help understanding this. Program for class and I'm not expecting an answer per say, but an explanation on how to start the loop.

I have to determine if a number is prime or not using a for loop.
I have the return false if it's 0,1, or negative. I need this:

the function should use a for loop to test if there are any devisors of the number (x) that do not result in a reminder.

I don't know how to set up the for loop to test devisors.. This is where i'm stuck:

Code
if (x == 0 || x == 1 || x < 0) {
return false;
}
else {
for (x; x > 1; x++){

}
}


Help is cool :)!

This post was edited by ChunkyFunk on Oct 9 2015 12:14pm
Member
Posts: 3,523
Joined: Sep 10 2011
Gold: 1,585.00
Oct 9 2015 12:44pm
Quote (ChunkyFunk @ Oct 9 2015 02:13pm)
Need a little help understanding this. Program for class and I'm not expecting an answer per say, but an explanation on how to start the loop.

I have to determine if a number is prime or not using a for loop.
I have the return false if it's 0,1, or negative. I need this:

the function should use a for loop to test if there are any devisors of the number (x) that do not result in a reminder.

I don't know how to set up the for loop to test devisors.. This is where i'm stuck:

Code
if (x == 0 || x == 1 || x < 0) {
return false;
}
else {
for (x; x > 1; x++){

}
}


Help is cool :)!


figured it out.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll