# Neighbouring numbers summing to a prime on a 3x3

Can you place distinct numbers from 0 to 9 on a 3x3 grid such that every pair of neighbouring (horizontally and vertically) numbers sum to a prime? Can you find multiple solutions? Note that the placed numbers can only be used once and one number will remain unused. The generated primes can be reused.

Good luck!

Yes

Explanation:

650
123
498

Where the generated primes in the rows are 11, 5, 3, 5, 13, 17 respectively, and in the columns 7, 5, 7, 11, 3 and 11.

Further:

You can generate multiple solutions from reflecting and rotating this grid. I don't know if you can make any more solutions which are fundamentally different from this, though I haven't tried.

No, it's not possible.
Due to in 3x3 grid, there are total 12 neighboring pairs. And consider to combination in 0~9, we can have minimal pair result $$0+1=1$$ and maximum pair result $$8+9=17$$. However in the first 12 primes are: $$2,3,5,7,11,13,17,23,29,31,37,41$$. Hence it's not possible.

Update:
After questions has been added "The generated primes can be reused." criteria, I've found one:

0 5 6
3 2 1
8 9 4
And you could get another solution by flip or rotate this to get a new one.

• You can reuse the generated primes. Sep 24, 2019 at 5:37
• Well, you just edited after the answer... Sep 24, 2019 at 5:41
• Sorry about that. I just clarified the question. I didn't downvote you. Sep 24, 2019 at 5:45
• Well I thought it was well formed... numbers cannot be reused while I didn't say anything about reusing primes. I added the extra bit just to make sure it's clear. Sep 24, 2019 at 5:57
• OK nevermind. I just think too much. Sep 24, 2019 at 5:59

By brute force computer search, I've found

there are 4 distinct solutions (ignoring rotations and reflections)

They are

038
529
614

038
749
612

129
438
705

129
658
703


• I wrote out a big long answer with a mathematical way of calculating all the permutations (84), and then saw your answer and realized that 1 is not prime... :( Sep 24, 2019 at 16:52