Im talking about this question, take a look at it if you are a bit confused.
Main Task
Your task is to output concatenated integers, in decreasing order, but increasing the maximum integer everytime you hit 1
(for this question, 1 will be considered a prime number). While this doesn't sound any different from the first question, here comes the tricky part: All outputted numbers may only be primes. These will be strung together into a single string without spaces or newlines. Your input will also be a prime number.
Example:
1
21
321
5321
75321
1175321
Valid output:
1213215321753211175321
Input
Your code may only take one input: the highest prime to be printed. This input can come from anywhere (graphical, STDIN). You are assured that the input is a prime number.
Output
You will have to output the resulting number. You can get this number by keep counting down, only count the number if it's a prime, then connect all results together to one number. The last number "row" (e.g. 7, 5, 3, 2, 1
) has to be printed fully. The output could be anything (numbers, strings, graphical), as long as it's readable. The same Regex pattern for checking your test cases applies:
^(\D*(\d)+\D*|)$
If your output doesn't match with this pattern, your code is invalid.
Rules
- The input is assured to be prime, do not include error handling, unless you want/need to.
- The output may only be a full-connected number, therefore not split up by anything, not even newlines.
- Your algorithm shouldn't check for the first instance of
N
appearing (for instance, the17
in1175321
), but rather for the first instance ofN
as the actual number. - Your input is assured to be positive, do not add handling unless you want/need to.
Test cases
Input: -2, 0
Output: Any, or none (number isn't positive)
Input: 9
Output: Any, or none (number isn't prime)
Input: 1
Output: 1
Input: 7
Output: 121321532175321
Input: 23
Output: 1213215321753211175321131175321171311753211917131175321231917131175321
Winner
This is code-golf, so the author of the code with the least length in bytes wins!
1
is a prime by definition. \$\endgroup\$1
directly contradicts the spec, which "assures" that the input number will be a prime. 2. The output spec seems to contain multiple contradictions and ambiguities. "The last number "row" (e.g. 7, 5, 3, 2, 1) has to be printed fully" - so the others don't? "The same Regex pattern for checking your test cases applies", but "The output may only be a full-connected number, therefore not split up by anything" contradicts that regex. But the regex is clearly dodgy anyway because it allows the empty string, and there's no input which could give that. \$\endgroup\$