-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Currently the sieve_of_eratosthenes
method has an optimisation: all primes other than 2 are a multiple of 2, so that only odd numbers must be checked. This gives roughly a 2x speed up and reduces memory usage by about half.
We can add a similar optimisation by also treating multiples of 3 as a special case: only numbers of form 6n+1 and 6n-1 have to be checked, as all other numbers are multiples of 2 or 3. See https://www.quora.com/Why-do-prime-numbers-always-satisfy-the-6n+1-and-6n-1-conditions-Is-there-any-mathematical-logic-behind-it. This should reduce execution time and memory usage by about a third.
Metadata
Metadata
Assignees
Labels
No labels