Re: Sieve of Erastosthenes optimized to the max
Sujet : Re: Sieve of Erastosthenes optimized to the max
De : vir.campestris (at) *nospam* invalid.invalid (Vir Campestris)
Groupes : comp.lang.c++Date : 16. May 2024, 18:28:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v25c87$1ld9m$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
User-Agent : Mozilla Thunderbird
I've been playing with this. Has it really been this long? I ought to have more time than this...
I put together some code, and have been playing with it far too much.
Bonita, I don't know whether to curse you or kiss you. (Though in fact I suspect you may be a little young for me. Possibly too young for my kids...)
I haven't written any code just for fun in years. Maybe decades!
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. Maybe I'll try one day ;)
My code isn't as fast as Bonita's code. Even allowing that I didn't put any threads in there.
But...
When I compared the output there were differences. Specifically your program claimed that these numbers
66049,67591,69133,69647,71189,72217,72731,75301,78899,79927,80441,81469,85067,86609,89179,
89693,90721,92263,94319,95861,97403,98431,99973,102029,103057,105113,107683,108197,110767,
111281,112823,113851,115393,117449,118477,118991,120019,123103,125159,126187,128243,129271,
130813,133897,134411,139037,140579,143149,144691,146233,146747,148289,150859,152401,153943,
154457,155999,157541,158569,159083,162167,164737,165251,166279,167821,169363,169877,172961,
173989,175531,177587,180157,182213,184783,186839,188381,189923,190951,193007,194549,195577,
197633,198661,202259,204829,207913,208427,210997,211511,212539,213053,215623,219221,220249,
220763,221791,225389,226417,226931,227959,233099,234127,236183,238753,240809,241837,243379,
244921,248519,249547,251089,252631,254687,256229,259313,260341,261883,262397,264967,265481,
267023,269593,270107,272677,273191,274733,279359,280387,280901,281929,283471,285013,287069,
288611,290153,295807,296321,298891,300947,303517,305059,306601,308657,311741,312769,314311,
315853
are all prime. They aren't. The first one is 257 squared, and the others all have factors too.
I'd also suggest that you comment demonstration code. It's intended to show off fancy techniques, and they aren't obvious without explanation.
I learned that lesson when I was a student, when I couldn't understand something I'd written myself!
Andy
Haut de la page
Les messages affichés proviennent d'usenet.
NewsPortal