n
prime numbersnth
prime numbern
or the range as an array. The second will receive a boolean, that specifies if the function returns the prime numbers as an array or a single number(the number of primes in the range or the nth
prime). According to the parameters the function should return an array.
primeGenerator
should be a function.
testString: assert(typeof primeGenerator === 'function');
- text: primeGenerator(20, true)
should return [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
.
testString: assert.deepEqual(primeGenerator(20, true), [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]);
- text: primeGenerator([100, 150], true)
should return [101, 103, 107, 109, 113, 127, 131, 137, 139, 149]
.
testString: assert.deepEqual(primeGenerator([100, 150], true), [101, 103, 107, 109, 113, 127, 131, 137, 139, 149]);
- text: primeGenerator([7700, 8000], false)
should return 30
.
testString: assert.equal(primeGenerator([7700, 8000], false), 30);
- text: primeGenerator(10000, false)
should return 104729
.
testString: assert.equal(primeGenerator(10000, false), 104729);
```