# Numbers at the corners of concentric squares (part 2)

Put 4 distinct 1-digit non-negative numbers (A, B, C, D) on every vertex of a rectangle.

Then put the last digit of the product of 2 connected vertices at the sides of the rectangle.

Create a smaller rectangle connecting the sides of the bigger rectangle.

Do the above procedure 5 more times (using the 4 new numbers which do not have to be distinct).

The last 4 numbers must be (1,1,1,1).

E = last digit of (A×B)           G = last digit of (B×D)
H = last digit of (C×D)           F = last digit of (A×C)
I = last digit of (F×E)           J = last digit of (E×G)
K = last digit of (F×H)           L = last digit of (H×G)
and so on....


Find (A, B, C, D)

Note: Every permutation of (A,B,C,D) will yield the same result (1,1,1,1).

It seems that

9, 7, 3, 1

is working. I found this by computer.

The stage before $(1,1,1,1)$ must be

one of $(1,1,1,1)$ itself,
$(9,9,9,9)$, or
$(3,7,3,7)$ - 7 opposite 7 [& 3 opposite 3] ($3\times 3$ and $7\times 7$ do not end in $1$.)
- thanks to Etoplay for spotting the last one, I totally discounted it when considering the multiplication noted above!

the stage before

a $(9,9,9,9)$ must be
one of $(3,3,3,3)$, $(7,7,7,7)$, $(1,9,1,9)$ - with 9 opposite 9 [and 1 opposite 1]

now

the $(3,3,3,3)$ needs $(1,3)$ or $(7,9)$ pairs, not getting us further toward the outer distinct requirement

similarly

the $(7,7,7,7)$ needs $(1,7)$ or $(3,9)$ pairs.

but

For the $(1,9,1,9)$ we can shift the opposite pairs by using $(3,7)$ and $(7,3)$

and then

break the $(3,3,7,7)$ into $(3,1,3,9)$ which we can then break into $(1,3,7,9)$.

This does it in five steps, but $(1,1,1,1)$ goes to $(1,1,1,1)$.

which yields a solution of

$(1,3,7,9) \rightarrow (3,1,3,9) \rightarrow (3,3,7,7) \rightarrow (9,1,9,1) \rightarrow (9,9,9,9) \rightarrow (1,1,1,1) \rightarrow (1,1,1,1)$

We can also see that

the $(3,3,3,3)$ and $(7,7,7,7)$ both take us out to useless trails containing the patterns $(1,3,1,3)$, $(7,9,7,9)$, $(3,3,3,3)$, $(7,7,7,7)$, $(1,7,1,7)$, $(1,9,1,9)$, and $(3,9,3,9)$.

If we try with the

$(3,7,3,7)$ found at the start we see that we can go directly to $(1,3,9,7)$!

Checking the

$3024$ possible starting arrangements (ignoring $0$ since it will only lead to more zeros) the valid ones are indeed all $24$ permutations of $(1,3,7,9)$:

from itertools import combinations, permutations
target = [1,1,1,1]
for choice in combinations(range(1, 10), 4):
for outerSquare in permutations(choice):
squares = [list(outerSquare)]
while len(squares) <= 6:
nextIn = [(x*y)%10 for x,y in zip(squares[-1], squares[-1][1:] + [squares[-1][0]])]
squares.append(nextIn)
if nextIn == target:
break
else:
continue
print(squares)

[[1, 3, 7, 9], [3, 1, 3, 9], [3, 3, 7, 7], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[1, 3, 9, 7], [3, 7, 3, 7], [1, 1, 1, 1]]
[[1, 7, 3, 9], [7, 1, 7, 9], [7, 7, 3, 3], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[1, 7, 9, 3], [7, 3, 7, 3], [1, 1, 1, 1]]
[[1, 9, 3, 7], [9, 7, 1, 7], [3, 7, 7, 3], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[1, 9, 7, 3], [9, 3, 1, 3], [7, 3, 3, 7], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[3, 1, 7, 9], [3, 7, 3, 7], [1, 1, 1, 1]]
[[3, 1, 9, 7], [3, 9, 3, 1], [7, 7, 3, 3], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[3, 7, 1, 9], [1, 7, 9, 7], [7, 3, 3, 7], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[3, 7, 9, 1], [1, 3, 9, 3], [3, 7, 7, 3], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[3, 9, 1, 7], [7, 9, 7, 1], [3, 3, 7, 7], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[3, 9, 7, 1], [7, 3, 7, 3], [1, 1, 1, 1]]
[[7, 1, 3, 9], [7, 3, 7, 3], [1, 1, 1, 1]]
[[7, 1, 9, 3], [7, 9, 7, 1], [3, 3, 7, 7], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[7, 3, 1, 9], [1, 3, 9, 3], [3, 7, 7, 3], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[7, 3, 9, 1], [1, 7, 9, 7], [7, 3, 3, 7], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[7, 9, 1, 3], [3, 9, 3, 1], [7, 7, 3, 3], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[7, 9, 3, 1], [3, 7, 3, 7], [1, 1, 1, 1]]
[[9, 1, 3, 7], [9, 3, 1, 3], [7, 3, 3, 7], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[9, 1, 7, 3], [9, 7, 1, 7], [3, 7, 7, 3], [1, 9, 1, 9], [9, 9, 9, 9], [1, 1, 1, 1]]
[[9, 3, 1, 7], [7, 3, 7, 3], [1, 1, 1, 1]]
[[9, 3, 7, 1], [7, 1, 7, 9], [7, 7, 3, 3], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]
[[9, 7, 1, 3], [3, 7, 3, 7], [1, 1, 1, 1]]
[[9, 7, 3, 1], [3, 1, 3, 9], [3, 3, 7, 7], [9, 1, 9, 1], [9, 9, 9, 9], [1, 1, 1, 1]]

• Can't the second square be (3,7,3,7) only 3 and 7 will be multiplied. No 3*3 or 7*7. – Etoplay Oct 25 '16 at 8:16
• Err, yes it could. – Jonathan Allan Oct 25 '16 at 8:17
• I didn't follow your reasoning closely, but in the last line you argue that you verify your solution. However, OP states that all permutation of the initial quadruple should lead to the (1,1,1,1) final state which in effect multiplies up your quick check of ... possibilities by a factor 24. – Matsmath Oct 25 '16 at 8:32
• @Matsmath as noted by Etoplay I missed a choice at the start, which indeed leads to a shorter path to the same choices. – Jonathan Allan Oct 25 '16 at 8:43
• I made a graph of the solutions for those interested. – 2012rcampion Oct 25 '16 at 23:38

1, 3, 7, 9.

I almost went to code this but figured it out in my head. Great puzzle!

Any odd number number times an even number gives an even number, and numbers have to be odd. If only one of A, B, C, or D is even, all numbers will be even by the third iteration of the procedure. So A, B, C, and D are all odd. This narrows it down to 5 options.

.

Did someone say 5? Well, any odd number times 5 ends in 5, so if 5 is one of A, B, C, or D, then all numbers will be 5 by the third iteration of the procedure. This excludes 5.

.

All that remains are 1, 3, 7, and 9. The first iteration of these numbers yields 3, 7, 3, and 7, which then yield 1, 1, 1, 1.

.

You only need to do the procedure twice to get this result. Why stipulate 6 iterations? To make it more daunting?

.

• 6 iterations guarantees that any combination of those numbers works. See my answer for details. – Peter Taylor Oct 26 '16 at 13:20

Labelling the corners of the first square consecutively as $A,B,C,D$; the corners of the subsequent squares are:

• $AB, BC, CD, AD \pmod{10}$
• $AB^2C, BC^2D, ACD^2, A^2BD \pmod{10}$
• $AB^3C^3D, ABC^3D^3, A^3BCD^3, A^3B^3CD \pmod{10}$

So we can already rule out any of $A,B,C,D$ being in

$\{0,2,4,5,6,8\}$ since we end up with $1$s and so $ABCD$, which divides all of the corners from here on in, must be coprime with $10$.

But then by elimination we have

$\{A,B,C,D\} = \{1,3,7,9\}$.

To verify that these work in any order, we can continue for the remaining three squares:

• $A^2B^4C^6D^4, A^4B^2C^4D^6, A^6B^4C^2D^4, A^4B^6C^4D^2 \pmod{10}$
• $A^6B^6C^{10}D^{10}, A^{10}B^6C^6D^{10}, A^{10}B^{10}C^6D^6, A^6B^{10}C^{10}D^6 \pmod{10}$
• $A^{16}B^{12}C^{16}D^{20}, A^{20}B^{16}C^{12}D^{16}, A^{16}B^{20}C^{16}D^{12}, A^{12}B^{16}C^{20}D^{16} \pmod{10}$

And then observe that the innermost square is $$(A^4B^3C^4D^5)^4, (A^5B^4C^3D^4)^4, (A^4B^5C^4D^3)^4, (A^3B^4C^5D^4)^4 \pmod{10}$$ and that

$1^4 \equiv 3^4 \equiv 7^4 \equiv 9^4 \equiv 1 \pmod {10}$

• Proof from the book. – Matsmath Oct 25 '16 at 19:21