Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: Sieve of Erastosthenes optimized to the max Date: Tue, 21 May 2024 19:06:07 -0700 Organization: A noiseless patient Spider Lines: 23 Message-ID: <86r0duwqgg.fsf@linuxsc.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Wed, 22 May 2024 04:06:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ef527a1f0ace8b0bcb46bd1e68f4f6ae"; logging-data="1042967"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OVfKCw9pLdZWtJ8A2c5h5tu8VizIRbU4=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:1sqEPJFI8gZU/OWVOL/nO6zybjI= sha1:8S64xP4DIV0CPcGhbdUsQoGm/c8= Bytes: 2771 Vir Campestris writes: > I've been playing with this. Has it really been this long? I > ought to have more time than this... [...] > > I missed Tim's Mod 30 trick, and that might well help. But I > think I'm bored with this. It would save a lot of memory, but > the extra computation might make it slower. Two comments. Using the mod 30 encoding can be speed competitive with simpler encodings. The second comment is, it isn't just that less memory is used, but that more primes can be found. Bonita brags about how fast some code is, but it's an apples and oranges comparison - that code doesn't do the job because it runs into a memory limit way sooner than using a mod 30 encoding, and trying to run past that limit would make the code R E A L L Y S L O W. > Maybe I'll try one day ;) I hope you do. If you have some difficulty seeing how to avoid the seeming speed penalties, feel free to ask, I am happy to help.