Prime numbers: Added description, removed unnecessary implementation, and improved current#5048
Closed
matssson wants to merge 1 commit intoTheAlgorithms:masterfrom
matssson:primenumbers
Closed
Prime numbers: Added description, removed unnecessary implementation, and improved current#5048matssson wants to merge 1 commit intoTheAlgorithms:masterfrom matssson:primenumbers
matssson wants to merge 1 commit intoTheAlgorithms:masterfrom
matssson:primenumbers
Conversation
…he current implementation by incrementing by 2 instead of 1
14 tasks
poyea
reviewed
Oct 6, 2021
poyea
reviewed
Oct 6, 2021
Comment on lines
-35
to
-49
| >>> list(primes(0)) | ||
| [] | ||
| >>> list(primes(-1)) | ||
| [] | ||
| >>> list(primes(-10)) | ||
| [] | ||
| >>> list(primes(25)) | ||
| [2, 3, 5, 7, 11, 13, 17, 19, 23] | ||
| >>> list(primes(11)) | ||
| [2, 3, 5, 7, 11] | ||
| >>> list(primes(33)) | ||
| [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31] | ||
| >>> list(primes(10000))[-1] | ||
| 9973 | ||
| """ |
Author
There was a problem hiding this comment.
The tests dont make sense since we removed one of the functions, it just compared the two timings
Member
poyea
reviewed
Oct 6, 2021
Comment on lines
-26
to
-29
| if (i % j) == 0: | ||
| break | ||
| else: | ||
| yield i |
poyea
reviewed
Oct 6, 2021
Comment on lines
+4
to
+10
| """ | ||
| Naive implementation of finding primes by checking if each number | ||
| is divisible by 2 or any odd number up to its root. | ||
|
|
||
| For a fast implementation see Sieve of Eratosthenes. | ||
| """ | ||
|
|
Member
There was a problem hiding this comment.
ok to keep an explanation, but state that there are two impls, and you can compre both.
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Added description, removed unnecessary implementation, and improved the current implementation by incrementing by 2 instead of 1. I kept the name slow_primes around to emphazise that this is not a very good method of finding primes. This is also apparent from the description
Checklist:
Fixes: #{$ISSUE_NO}.