Erythro/tests/sieve.er
2023-12-08 03:01:56 +00:00

30 lines
481 B
Plaintext

import "import/defs.eh"
long num[100];
int :: main() {
long i = 0;
long j = 0;
for (i = 0; i < 100; i++) {
num[i] = i + 1;
}
for (i = 1; (num[i] * num[i]) <= 100; i++) {
if (num[i] != 0) {
for (j = num[i] * num[i]; j <= 100; j = num[i] + j) {
num[j - 1] = 0;
}
}
}
printf("Finding primes 2..%d\n\n",100);
for (i = 1; i < 100; i++) {
if (num[i] != 0) {
printf("%d\t", num[i]);
}
}
printf("\n");
return (0);
}