# Prime sums in a 3x3 grid

Can you place the first 9 odd primes in a 3x3 grid such that every row, column and both diagonals sum to a prime? The sums do not need to be distinct.

This should do it:

$$\begin{array}{|c|c|c|} \hline 11 & 17 & 19 \\ \hline 3 & 29 & 5 \\ \hline 23 & 7 & 13 \\ \hline \end{array}$$

That is, the sums are:
First row, $$11+17+19 = 47$$
Second row, $$3+29+5 = 37$$
Third row, $$23+7+13 = 43$$
First col., $$11+3+23 = 37$$
Second col., $$17+29+7 = 53$$
Third col., $$19+5+13=37$$
Anti-diagonal, $$23+29+19=71$$
Diagonal, $$11+29+13=53$$

This is not a unique solution, for instance, the following also works:
$$\begin{array}{|c|c|c|} \hline 19 & 7 & 17 \\ \hline 5 & 29 & 3 \\ \hline 13 & 11 & 23 \\ \hline \end{array}$$

• This is a symmetry of my answer, which was invalid as it uses 31, the 11th prime and the 10th odd prime. Feb 19, 2022 at 10:46
• @WeatherVane, you are right, I edited with a correct answer
– JKHA
Feb 19, 2022 at 10:51
• I found the flaw in my solution. Feb 19, 2022 at 11:12
• There are a total of 116 distinct solutions. Feb 19, 2022 at 11:12
• @TMK, I coded an algorithm to find it. The number of possibilities is quite small :) I have not enough background to get such answers only with mathematics, pencil and paper haha
– JKHA
Apr 12, 2022 at 13:29

Of 116 distinct solutions, there is a unique solution with distinct sums:

$$\begin{array}{|c|c|c|}\hline 7 & 5 & 19 \\ \hline 13 & 11 & 29 \\ \hline 17 & 3 & 23 \\ \hline \end{array}$$

Row sums: $$31, 53, 43$$
Column sums: $$37, 19, 71$$
Diagonal sums: $$41, 47$$

• I like the distinct primes of the sums of this solution. That said, about being "unique", for every solution like this, one can get three more by rotating the solution 90, 180, or 270 degrees. Or by flipping the solution around the central row, or flipping around the central column. Either of the flipped versions can also be rotated. One could also swap every value (except the center) with the value opposite to it across the center (point symmetry) and that can be rotated as well. Some of these combinations will be duplicates. But all will have exactly the same set of distinct sums.
– Eric
Feb 19, 2022 at 19:57
• I wonder if by "distinct solution" you mean something like "has a distinct set of primer sums or something like that. Certainly there are equivalent arrangements (see my previous comment, plus I forgot to mention flipping along each diagonal) that get the same sums. So perhaps you are considering all of these together to be one "solution"?
– Eric
Feb 19, 2022 at 20:01
• @Eric Two solutions are distinct if one cannot be obtained through rotation and/or reflection of the other. There are a total of 928 solutions, and the eight-fold symmetry of the grid reduces this to 116 distinct solutions. This solution is unique because, apart from rotations and reflections, no other solution has 8 different sums. Feb 19, 2022 at 21:17