User talk:Spoon!: Difference between revisions
→Python/Java infinite generator/iterator error: applies only to fixed types of Java...
GordonBGood (talk | contribs) |
GordonBGood (talk | contribs) (→Python/Java infinite generator/iterator error: applies only to fixed types of Java...) |
||
Line 57:
== Python/Java infinite generator/iterator error ==
Spoon!, your Java Sieve of Eratosthenes infinite generator [http://rosettacode.org/wiki/Sieve_of_Eratosthenes#
A better fix would be to postpone the addition of the prime multiple culling sequences to the queue until needed as was done for the dictionary solution (the faster algorithm), in which case the algorithm will work up to the full numeric range of whatever number type is used, including 32-bit integers (2^31 - 1 or 2,147,483,647) otherwise limited to a rage of 46,349. This has the further advantage of much less memory use (by about the ratio of the square root of the memory used) and faster queue re-insertions (a large fraction of the total operations) as these access times are proportional of the log of the queue size, which would then be smaller by the given square root ratio.--[[User:GordonBGood|GordonBGood]] ([[User talk:GordonBGood|talk]])
|