#include <iostream> using namespace std; int isSimple (int x) { int retVal = 1; int i = 2; while (i<=sqrt((double)x) && retVal==1) { if (x%i==0) retVal=0; i++;
} return retVal; }
void main(){ int n(0); cout<<"write n "; cin>>n; if (n < 3) cout<<"error"; else { for (int i=2;i<=n;i++) if (isSimple(i)) cout<<i<<" "; } cout<<endl; system("pause"); }
#include <iostream>
using namespace std;
int isSimple (int x)
{
int retVal = 1;
int i = 2;
while (i<=sqrt((double)x) && retVal==1)
{
if (x%i==0) retVal=0;
i++;
}
return retVal;
}
void main(){
int n(0);
cout<<"write n "; cin>>n;
if (n < 3)
cout<<"error";
else {
for (int i=2;i<=n;i++)
if (isSimple(i)) cout<<i<<" ";
}
cout<<endl;
system("pause");
}