Write a generator of prime numbers, in order, that will automatically adjust to accommodate the generation of any reasonably high prime.
The generator should be able to : Show the first n prime numbers.Show the prime numbers in a range.Show the number of primes in a range.Show the nth prime number.The function should have two parameters. The first will receive n 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
is a function.
testString: assert(typeof primeGenerator === 'function', 'primeGenerator
is a function.');
- text: primeGenerator
is a function.
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], 'primeGenerator
is a function.');
- text: primeGenerator
is a function.
testString: assert.deepEqual(primeGenerator([100, 150], true), [101, 103, 107, 109, 113, 127, 131, 137, 139, 149], 'primeGenerator
is a function.');
- text: primeGenerator
is a function.
testString: assert.equal(primeGenerator([7700, 8000], false), 30, 'primeGenerator
is a function.');
- text: primeGenerator
is a function.
testString: assert.equal(primeGenerator(10000, false), 104729, 'primeGenerator
is a function.');
```