0

Hey,

Ive got a program I'm try to work on that the user enters the number and then it reports back if the number is prime or not. So far my calculations are completely off and I have no idea how to fix them or what they should be. Any help would be great.

```
#include <iostream>
#include <math.h>
using namespace std;
bool isPrime(int);
int getNumber();
int main()
{
int number = getNumber();
if (isPrime(number))
cout << "\n" << number << "is a prime number\n";
else
cout << "\n" << number << "is not a prime number\n";
return 0;
}
int getNumber()
{
int number;
cout << "Please enter a positive number ";
cin >> number;
if (!cin.good())
{
printf("Invalid number entered\n");
exit(1);
}
return number;
}
bool isPrime(int number)
{
int count, s;
bool isprime = true;
/* Every even number is not prime */
if (number % 2 == 0) return true;
/* check every odd number up to the square root of the number */
s = sqrt(number);
for (count=1; count<=s; count+=2);
{
if (number % count == 0)
isprime = false;
}
return false;
}
```