#include <iostream>
usingnamespace std;
bool prime (int);
void main ()
{
int n, value;
while (true)
{
cout << "Enter n (n >= 2): "; cin >> n;
cout << endl << "Prime numbers less than or equal to " << n << ":" << endl;
for (value = 2; value <= n; value++)
{
if (prime (value))
cout << value << " ";
}
cout << endl << endl;
}
}
bool prime (int value)
{
int i;
for (int i = 2; sqrt (double (value)); i++)
{
if (value % i == 0)
{
returnfalse;
}
}
returntrue;
}