-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Resolve duplicate entries for sieve of eratosthenes #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
raklaptudirm
merged 8 commits into
TheAlgorithms:master
from
SpiderMath:remove-Eratosthenes-intarray
Jan 12, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ce13a0b
remove intarr test
SpiderMath b037bb5
Remove main file oops
SpiderMath e3ef5c3
FIXES: #1666 , remove references to SieveOfEratosthenesIntArray
SpiderMath 3e4176e
Merge branch 'TheAlgorithms:master' into remove-Eratosthenes-intarray
SpiderMath 98baa86
Finally fix the requirements, passes vitest
SpiderMath ab2df02
Updated Documentation in README.md
SpiderMath 8f9269e
FIXES: #1666 and conform to alg comment standards
SpiderMath fcd636a
Merge branch 'remove-Eratosthenes-intarray' of https://github.com/Spi...
SpiderMath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import { sieveOfEratosthenes } from '../SieveOfEratosthenes' | ||
import { PrimeCheck } from '../PrimeCheck' | ||
|
||
describe('should return an array of prime booleans', () => { | ||
it('should have each element in the array as a prime boolean', () => { | ||
const n = 30 | ||
const primes = sieveOfEratosthenes(n) | ||
primes.forEach((primeBool, index) => { | ||
if (primeBool) { | ||
expect(PrimeCheck(index)).toBeTruthy() | ||
} | ||
}) | ||
|
||
describe('sieveOfEratosthenes', () => { | ||
test('returns an empty array for max < 2', () => { | ||
expect(sieveOfEratosthenes(1)).toEqual([]) | ||
}) | ||
|
||
test('returns [2] for max = 2', () => { | ||
expect(sieveOfEratosthenes(2)).toEqual([2]) | ||
}) | ||
|
||
test('returns [2, 3] for max = 3', () => { | ||
expect(sieveOfEratosthenes(3)).toEqual([2, 3]) | ||
}) | ||
|
||
test('returns [2, 3, 5, 7] for max = 10', () => { | ||
expect(sieveOfEratosthenes(10)).toEqual([2, 3, 5, 7]) | ||
}) | ||
|
||
test('returns [2, 3, 5, 7, 11, 13, 17, 19] for max = 20', () => { | ||
expect(sieveOfEratosthenes(20)).toEqual([2, 3, 5, 7, 11, 13, 17, 19]) | ||
}) | ||
|
||
test('returns [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] for max = 30', () => { | ||
expect(sieveOfEratosthenes(30)).toEqual([ | ||
2, 3, 5, 7, 11, 13, 17, 19, 23, 29 | ||
]) | ||
}) | ||
}) |
Oops, something went wrong.
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
Oops, something went wrong.
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.