I am looking to write a function that accepts 2 arguments.
- A single positive integer, "n"
- A logical indicator, "all"
The function should do the following:
If TRUE, return the first n prime numbers as a single vector.
ELSE return only the n-th prime number.
The output should be:
genprime(7, all=TRUE)
[1] 2 3 5 7 11 13 17
genprime(7, all=FALSE)
[1] 17