Extensible prime generator
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.
Test
{{test}}Console output