D2 code, the 8191 too is counted: import std.stdio: writeln; int sieve(int m) { auto isPrime = new bool[m + 1]; isPrime[] = true; int count; foreach (i; 2 .. isPrime.length) { if (isPrime[i]) { count++; for (int k = i * 2; k < isPrime.length; k += i) isPrime[k] = false; } } return count; } void main() { writeln(sieve(8191)); } Bye, bearophile