@dxzmpk/js-algorithms-data-structures
Version:
Algorithms and data-structures implemented on JavaScript
13 lines (11 loc) • 449 B
JavaScript
import sieveOfEratosthenes from '../sieveOfEratosthenes';
describe('sieveOfEratosthenes', () => {
it('should find all primes less than or equal to n', () => {
expect(sieveOfEratosthenes(5)).toEqual([2, 3, 5]);
expect(sieveOfEratosthenes(10)).toEqual([2, 3, 5, 7]);
expect(sieveOfEratosthenes(100)).toEqual([
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
]);
});
});