#include <iostream>
usingnamespace std;
int main()
{
int i, number, range;
number = 1;
i = 1;
int counter;
counter = 0;
cout << "Enter a number to set the range:" << endl;
cin >> range;
while (number <= range) {
while(i <= number) {
if (number % i == 0) {
counter++;
}
i++;
if (counter == 2) {
cout << number << " is a prime number." << endl;
counter = 0;
}
}
i = 1;
number++;
}
return 0;
}
bool IsPrime(unsignedint n)
{
// 0 or 1 is not prime
if(n == 0 || n == 1) return 0;
// 2 and 3 are
if(n == 2 || n == 3) return 1;
// if number is even, definitely not prime
if(n % 2 == 0) return 0;
// if number is greater than 3 and not even
// test numbers against it
for(unsignedint i = 3; i < n/2+1; i+=2)
{
//if n / i = 0, not prime
if(n%i == 0) return 0;
}
// if execution gets here, it is a prime number
return 1;
}