Suppose I have a 3 by 3 grid. Can you fill the grid with numbers from 1 to 9 in such a way that the product of each row corresponds to each column? Is this possible for any n by n grid with numbers till n2? If so, why? Is there an efficient algorithm to do it? Is there a formula? I want more mathematically inclined answers.
-
2$\begingroup$ What does it mean to "correspond"? Are the row products supposed to result in the same numbers as the column products? $\endgroup$– AxiomaticSystemCommented Aug 28 at 9:00
-
$\begingroup$ @AxiomaticSystem yeah, $\endgroup$– SanskarsCommented Aug 28 at 9:40
-
4$\begingroup$ The same question has already been asked for 4x4, 5x5, 6c6 and other nxn. This MSE post has solutions for all cases. $\endgroup$– Jaap ScherphuisCommented Aug 28 at 11:03
4 Answers
It is possible. At least for 3x3.
5 1 6
2 7 4
3 8 9
With products 30, 56 and 216
-
$\begingroup$ Sorry to bother... how about 5*1*6 = 30, but 6*4*9 = 216? I mean, the product of 5, 1 and 6 is not equal to the product of 6, 4 and 9. Is there something I understand wrong? $\endgroup$– tToECommented Aug 28 at 11:02
-
$\begingroup$ It works like this that the product of the rows give 3 numbers, and the product of the columns give the same 3 numbers. $\endgroup$ Commented Aug 28 at 11:27
The question's meaning isn't perfectly clear. Here are two interpretations.
Interpretation 1: we want all the row products and all the column products equal to one another. This is
not possible for any $n$, despite Sanskar's comment on another answer.
Explanation:
By Bertrand's postulate, there is always a prime number between $n^2/2$ and $n^2$. Call it $p$. Unless $n^2=2p$, there are no multiples of $p$ other than $p$ itself between 1 and $n$ inclusive. (And if $n^2=2p$ then we must have $n=p=2$, and then we can use the prime 3 instead.) So now we have a prime $p$ that appears in the square, and no other multiple of $p$ appears in the square. But now the product of the numbers in the row $p$ appears in is a multiple of $p$, and the product of the numbers in any other row is not. So the row products are not all equal.
Interpretation 2: it's fine for the row products to differ, and fine for the column products to differ, but we want the row products to be the same numbers as the column products. This is
possible for $n=3$ and impossible for all large enough $n$; I have some reason to guess it is impossible for $n\geq9$; I haven't checked $n=4,5,6,7,8$ and don't have confident guesses about those.
Explanation:
Let's first of all consider $n=3$. Exactly one row and exactly one column contains a 5; being the only row whose product is a multiple of 5 and the only column whose product is a multiple of 5, their products must be equal. So the other two elements in the row, and the other two elements in the column, must have equal products. Similarly for the cell with a 7 in it. Further, the 5 and 7 can't be in the same row or column (that would give a multiple of 35 and nowhere else to put one), so we have (up to rearrangements of rows and columns) this picture:
5 a b c 7 f d e g
where
5ab=5cd and 7ae=7cf. So let's see what products of two things from 1..9 are equal. We have 16/23, 18/24, 26/34, 29/36, 38/46. This gives, if I haven't goofed,
516=523 718=724
561=523 763=729
561=532 762=734
561=532 764=738
526=534 729=736
562=534 764=738
and the same with 5,7 swapped. The first of these yields
5 1 6
2 7 4 3 8 9
which
does the job (products are 30, 56, 216, in that order, for rows and also for columns) so I haven't checked any of the others.
On the other hand,
if $n$ is large then of the $n^2/2$ numbers between $n^2/2$ and $n$, at least about a fraction $1/log n^2$ of them are prime, which means there are many more than $n$ primes in that range, which means that two of them appear in the same row. Then that row's product is a multiple of both primes, but no column's product is. This fails to rule out $n=4,5,6,7,8$ (for all of which there aren't quite enough suitably-sized primes) but does rule out $n=9$ and I suspect but haven't checked probably all larger $n$. I have not attempted to check whether the configuration is possible for $n=4,5,6,7,8$.
-
$\begingroup$ (While I was writing this, Florian F posted his answer; what I wrote about the n=3 case of interpretation 2 was written independently of Florian's post.) $\endgroup$– Gareth McCaughan ♦Commented Aug 28 at 11:28
For $3$ x $3$:
It doesn't matter which row corresponds to which column or where the row/column is, because trading places doesn't prevent a square from satisfying the conditions.
The primes $5$ and $7$ are important for a $3$x$3$ square. They can't be on the same row or column, because then they can't be on the other row/column where the other is to satisfy the conditions. So, let's have this:
$5$ $x$ $yn$
$y$ $7$ $xk$
$xn$ $yk$ $z$
$1$, $2$
$3$, $6$
$4$, $8$
So $x$ can be $1$, $y$ can be $2$ and $n=3$. This gives us:
$5$ $1$ $6$
$2$ $7$ $4$
$3$ $8$ $9$
Generalization (partial, rule of thumb):
Start with finding the primes that can't divide any other number (the ones larger than $n^2/2$) to put them all on a diagonal line. The diagonal isn't technically necessary, but it helps keep things tidy. But for some numbers, there are more primes between $n^2/2$ and $n^2$ than $n$, leaving no room for some primes, such as a $9$ x $9$ square.
For 3*3 grid:
It's impossible. Consider prime factorization, we have: $$ \begin{array}{cccccccc} 1 & 2 & 3 & 4 & 5 & 6 & 7& 8& 9 \\ \downarrow & \downarrow & \downarrow& \downarrow& \downarrow& \downarrow& \downarrow& \downarrow& \downarrow \\ 1 & 2 & 3 & 2^2 & 5 & 2\times 3 & 7 & 2^3 & 3^2 \\ \end{array} $$ We can notice that, there are only a single 5 and a single 7. If we put the digit 5 inside one of the 3*3 grid, for example $$ \begin{array}{ccc} 5 & A & B \\ ? & ? & C \\ ? & ? & D \\ \end{array} $$ then among the three digits $B$, $C$ and $D$, there must be another 5... That's impossible.
Similarly, it is impossible for another single digit 7.
-
-
1$\begingroup$ The question is not asking for a square where all the row products are the same and equal to the column products, only that the three row products and the three column products are the same set of three numbers. $\endgroup$ Commented Aug 28 at 10:59
-
$\begingroup$ @JaapScherphuis Oh! Thanks for your explanation!!! ...Now I understand. $\endgroup$– tToECommented Aug 28 at 11:04