project euler #10: optimization with primes
bearophile
bearophileHUGS at lycos.com
Wed Apr 1 03:21:52 PDT 2009
Robert Fraser Wrote:
> Yeah that's shorter (vertically; it's almost as long in characters),
This is simpler and faster (runs in 2.19 seconds), and gives the same result, xtakeWhile isn't required because xprimes already stops nicely when the given max N is reached:
import d.func, d.primes, d.string;
void main() {
putr( sum(xprimes(1_000_000_000)) );
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list