User talk:Retroburrowers: Difference between revisions
→reply2: corrected sqrt limit to reduce redundant looping with no difference in the answers...
GordonBGood (talk | contribs) m (→reply2: typos...) |
GordonBGood (talk | contribs) (→reply2: corrected sqrt limit to reduce redundant looping with no difference in the answers...) |
||
Line 143:
else: return 1
k = (n - 3) // 2 + 1; integers_list = [True] * k; ops = 0
for i in range(0, (int(math.sqrt(
# if integers_list[i]: # adding this condition turns it into a SoE!
p = 2 * i + 3; s = (p * p - 3) // 2 # compute cull start
Line 173:
Found 78498 primes to 1000000.</pre>
: This difference in the amount of operations as in the amount of work done gets even larger as the range goes up; if you want to play with it, the code is posted on [https://wandbox.org/permlink/
: That is the reason that the SoS should not be on the SoE Task Page: it doesn't have the same asymptotic complexity, it isn't that much simpler, and it is confusing for those that can't tell the difference.
|