The negative order integer challenge, but it's Prime Time!

Im talking about this question, take a look at it if you are a bit confused.

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:

• 1, |grep(*.is-prime, 2..$_): Sequence of 1 and primes... (1 2 3 5) • [,] ...: Reduce ("fold") over comma operator... (1 2 3 5) • [\,] ...: With intermediate results (triangular reduce)... ((1) (1 2) (1 2 3) (1 2 3 5)) • [\R,] ...: Apply reversing meta-operator to the comma... ((1) (2 1) (3 2 1) (5 3 2 1)) • [~] flat ...: Remove list nesting, and fold over string concat operator... 1213215321 (This is based on my answer for the previous challenge.) Mathematica, 61 bytes ToString/@(1<>Prime@Range[Range@PrimePi@#,0,-1]/.Prime@0->1)& Unnamed function taking an integer argument and returning a string. (If the input is not a prime, it just "rounds it down" to the nearest prime; if the input is nonpositive, it pretends it's 1.) This implementation uses the nasty trick from Martin Ender's answer to the similar previous challenge (who says this old dog can't learn new tricks?): abusing <> to flatten a nested list of integers. The nested list in question starts by generating a similar nested list as in that answer, with the appropriate length (given by PrimePi@#, the number of primes up to and including the input); then Prime is applied to every element. For example, for the input 5 which is the 3rd prime, the code Range[Range@PrimePi@#,0,-1] yields {{1,0},{2,1,0},{3,2,1,0}}, and applying Prime to each element yields {{2,Prime},{3,2,Prime},{5,3,2,Prime}} since the 1st, 2nd, and 3rd primes are 2, 3, and 5, respectively. I feel proud that I managed to add even more errors to Martin Ender's approach—Mathematica complains every time it writes Prime. Prime isn't a thing, but that's okay: /.Prime@0->1 turns them all into 1s. And we also want a 1 on the front, so we replace the "" from Martin Ender's answer with simply 1, which actually saves a byte. PHP, 72 bytes for(;$n<$argv;print$s=$n.$s)for($i=2;$i>1;)for($i=++$n;--$i&&$n%$i;); Run wit -r breakdown for(;$n<$argv; // loop$n up to argument:
print$s=$n.$s) // 2. prepend$n to $s, print$s
for($i=2;$i>1;)                 // 1. find next prime: break if $i<2 for($i=++$n;--$i&&$n%$i;);      // if $n is prime,$i is 1 after loop (0 for \$n=1)

jkf!tPTs}R1S