import std.stdio; void main() { size_t count; bool[8191] flags; writeln("10 iterations"); // using iter as a throwaway variable foreach (iter; 1 .. 11) { count = 0; flags[] = 1; foreach (index, flag; flags) { if (flag) { size_t prime = index + index + 3; size_t k = index + prime; while (k < flags.length) { flags[k] = 0; k += prime; } count += 1; } } } writefln("%d primes", &count); }

Anonymouse via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 1 07:16:41 PDT 2017


On Tuesday, 1 August 2017 at 14:08:26 UTC, enter per ner wrote:
> whats the mistake

For everyone's sanity: https://run.dlang.io/is/bjlaNy


More information about the Digitalmars-d mailing list