3-digit prime numbers must end in 1, 3, 7 or 9. This means the last row will be a 3-digit composite number consisting of 3 of these 4 digits. So the possibilities of the digits (in numerical order) are: 137, 139, 179, 379. The composite number must consist of one of these combinations of digits. 137: 137, 173, 317, 371, 713, 731; 139: 139, 193, 319, 391, 913, 931; 179: 179, 197, 719, 791, 917, 971; 379: 379, 397, 739, 793, 937, 973.
We can eliminate the prime numbers: 371, 713, 731, 319, 391, 913, 931, 791, 917, 793, 973, which are the only composites. At least one of these must be a candidate for the number in the last row. Each of these leaves 6 digits from which to make the prime number columns. They can be grouped as follows:
- {371 713 731} remaining digits: {2 4 5 6 8 9}
- {319 391 913 931} remaining digits {2 4 5 6 7 8}
- {791 917} remaining digits {2 3 4 5 6 8}
- {793 973} remaining digits {1 2 4 5 6 8}
For each group we need to find all the possible prime numbers that use pairs of remaining digits together with the the digits of the composite number on the last row. There are 30 permutations of 2 digits from 6, but we are constrained by the requirement to pick only prime numbers. For example, if we take 371 from group 1 and the first 2 digits of those remaining, we have 243, 247, 241, 423, 427 and 421, but of these 241 and 421 are the only primes. They could occupy the last column. Similarly if we combine 2 and 5 with the digits of 371, we have 257, 251, 523 and 521 as the primes.
The last column determines the end of each composite number. The last row has already been determined, and if the other two rows end in even digits or 5, those rows are bound to be composites. In the examples above, the last column was identified to contain 241 or 421, so the digits 2 or 4 would end both remaining rows and establish a composite number. So all that remains is to pick primes for two columns using the 4 remaining digits: 5, 6, 8 and 9. The number of permutations of 2 digits out of 4 is 12: (5,6), (5,8), (5,9), (6,8), (6,9), (8,9), (9,8), (9,6), (8,6), (9,5), (8,5), (6,5). Some of these are needed to produce a prime ending in 3 or 7. Let's look at some possibilities. If we select 5 and 6 for example, we'll be left with 8 and 9 as the last pair of digits. We cannot put 5 and 6 with 7, because they would produce a number divisible by 3, and if we put 9 and 8 with 7 we would produce a number divisible by 3. We know this, because if we add the digits of a number together and the result is divisible by 3 then the number is divisible by 3. Another fact worth noting is the sum of 3 consecutive digits is always divisible by 3: 1+2+3=6; 2+3+4=9; etc. so we need to avoid using consecutive digits when we're looking for prime numbers. The combination of 7, 8 and 9 or 5, 6 and 7 in any order has to be avoided, for example.
That means we eliminate (5,6) and move on to (5,8), leaving us with (6,9). 693 and 963 are both divisible by 3; 967 is prime, leaving us with 583 and 853, the latter of which is prime. So it looks like we're done: the columns are 853, 967 and 241 so the rows are 892, 564 and 371.
We know that this is not the only solution because 241 can be replaced by 421 to provide another solution.