First off, I do want to state that I have read the forums and have not found an issue directly regarding this exact problem, though it is possible I may have overlooked it or something and if so please just point me in the right direction and I will leave you alone.
The program I have been writing is a prime number checker, just to check to see if the number input is prime and list numbers up to that number that are prime also. The program is working fine, the listing functions correctly and it properly identifies whether the input is prime or not, except for one exception. When I entered the number 777 into the program, it states that it is prime, which is incorrect, same with 7777. I have been trying to figure this out for a couple days now to no avail. So, any help will be greatly appreciated. Here is the snippet of code that handles the input checker:
void userPrime(int num)
{
if(num == 2)
{
cout << "The user entered the number, " << num << ", this is a prime number.\n\n";
}
else
{
for(int c = 2;c <= num;c++)
{
numPrime = true;
if(num % c == 0)
{
numPrime = false;
}
if(numPrime == true)
{
cout << "The user entered the number, " << num << ", this is a prime number.\n\n";
break;
}
else
{
cout << "The user entered the number, " << num << ", this is not a prime number.\n\n";
break;
}
}
}
}