-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve duplicate entries for sieve of eratosthenes (#1770)
* remove intarr test * Remove main file oops * FIXES: #1666 , remove references to SieveOfEratosthenesIntArray * Finally fix the requirements, passes vitest * Updated Documentation in README.md * FIXES: #1666 and conform to alg comment standards --------- Co-authored-by: SpiderMath <SpiderMath@users.noreply.github.com>
- Loading branch information
1 parent
85a55da
commit a62a46e
Showing
6 changed files
with
49 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 | ||
]) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains 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