14
Given an input integer, n
, where n >= 0
, your task is to generate the first n
strong primes. For example, the sixth, seventh, and eighth primes are 13, 17, and 19, respectively:
(13 + 19) / 2 < 17
Therefore, 17 is a strong prime.
Input
- an integer
Output
- if
n
is 0- program: output nothing
- function: return an empty array
- if
n
is greater than0
- program: output the first
n
strong primes, each on its own line - function: return an array containing the first
n
strong primes
- program: output the first
Test cases
0
[]
4
[11, 17, 29, 37]
7
[11, 17, 29, 37, 41, 59, 67]
47
[11, 17, 29, 37, 41, 59, 67, 71, 79, 97, 101, 107, 127, 137, 149, 163, 179, 191, 197, 223, 227, 239, 251, 269, 277, 281, 307, 311, 331, 347, 367, 379, 397, 419, 431, 439, 457, 461, 479, 487, 499, 521, 541, 557, 569, 587, 599]
See also: Strong primes on OEIS
output n strong primes - Any n strong primes or the first n strong primes? A few test cases/examples of corresponding inputs and outputs would a nice addition to the challenge. – Mr. Xcoder – 2017-09-03T07:52:15.863
1@Mr.Xcoder: I've updated the spec; added a link to OEIS, as well. – Zach Gates – 2017-09-03T07:55:35.313
Does it really have to be a newline as delimiter? – Titus – 2017-09-03T11:49:15.103
@Titus: Yes it does. – Zach Gates – 2017-09-03T12:02:53.443
is it an "and" or an "or" in the spec? "output and return" or "output, or return"?? – Will Ness – 2017-09-03T22:14:57.937
@WillNess: Output if a program, return if a function. – Zach Gates – 2017-09-03T22:16:17.903
@WheatWizard: No; from your own comment: "not weak is different than strong". Also, that task is to determine whether or not an input,
n
, is a weak prime (but it's yours, so you know that). – Zach Gates – 2017-09-03T22:24:43.450@ZachGates Its the difference between less than and greater than. Just because not weak is not the same as strong does not mean this is not a dupe. This is a minuscule difference and definitely not a large enough one to warrant its own question. – Post Rock Garf Hunter – 2017-09-04T01:58:48.497