Many people find it easier to write out the algorithm on some paper before coding it...you just have to think about what a prime number is, and how one will identify it. It is a number that will be divisible by only itself and one. From that, one understands that if the condition
if(number%factor==0) evaluates to true and the factor was not one or the number, the number is not prime. Take a look here at a basic implementation:
CODE
bool isPrime(int factor)
{
bool retValue = true;
for(int i=1;i<=factor;i++)
{
if(((factor%i)==0) && i!=1 && i!=factor)
retValue = false;
}
return retValue;
}
You can see that the three conditions I mentioned are being tested for. Please not the code above is for demonstration purposes only, it can certainly be improved upon.