#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"); }