
EXAMPLE

For n=3: The permutations of {1, 2, 3} are {{1}, {2}, {3}, {1, 2}, {1, 3}, {2, 1}, {2, 3}, {3, 1}, {3, 2}, {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1}}, the concatenations are {1, 2, 3, 12, 13, 21, 23, 31, 32, 123, 132, 213, 231, 312, 321}, and the primes are {2, 3, 13, 23, 31}, so a(3) = 5.


MATHEMATICA

pp[n_] := Module[{m, lst = {}}, For[m = 1, m <= n, m++, AppendTo[lst, Length[Select[ToExpression@StringJoin@IntegerString@# & /@ Permutations[Range[m], All], PrimeQ[#] &]]]; ]; lst ]; pp[10] (* J. Stauduhar, Apr 28 2013*)
