program Eratos char[] sieve; int max; // maximum prime to be found int npp; // numbers per page { void put(int x) { if (npp == 10) {print(chr(13)); print(chr(10)); npp = 0;} print(x, 5); npp = npp + 1; } void found(int x) int i; { put(x); i = x; while (i <= max) {sieve[i] = 'o'; i = i + x;} } void main() int i, ready; { read(max); npp = 0; sieve = new char[max+1]; i = 0; while (i <= max) {sieve[i] = 'x'; i = i + 1;} i = 2; while (i <= max) { found(i); ready = 0; while(ready == 0) { if (i > max) ready = 1; else if (sieve[i] == 'x') ready = 1; else i = i + 1; } } } }//test