# Finding the nine - solution

in

Here is the solution of our puzzle Finding the nine. Did you get it right?

### Another solution to the puzzle

I just came across this is clever problem! My solution is largely similar to the video solution in that it uses modular arithmetic, but it doesn't use algebra. Like the video the solution uses the following divisibility rules:
a number is divisible by 3 if the sum of its digits is divisble by 3,
divisible by 6 if even and divisible by 3,
and that all 9-digit numbers made by permuting the digits 1..9 are divisible by 9, since their digit sum is 45, which is divisible by 9.

Here it is:

Let the letters a-i represent the nine digits in their respective positions: abcdefghi

1. That ab, abcd, abcdef, and abcdefgh are divisible by 2,4,6 and 8 --> b,d,f,h are even

2. #1 --> a,c,e,g,i are odd

3. abcde=0 mod 5 --> e=5

4. c is odd (#2) and cd=0 mod 4 --> d={2,6} (i.e. the 4-digit number ends in 12,16,32,36 etc.)

5. f is even (#1) and g is odd (#2) and abcdefgh=0 mod 8 --> gh={16,96,32,72} (i.e. gh are multiples of 8) & h={2,6}

6. #4 & #5 --> b={4,8} and f={4,8} (since 2 & 6 are used up only 4 & 8 remain)

The next couple of steps depend on mod 3 arithmetic and the fact that the sum of the digits of a number are 0 mod 3 for it to be divisible by 3. Written across my piece of paper I have
a = {1,3,7,9} = {1,0,1,0} mod 3
b = {4,8} = {1,2} mod 3
c = {1,3,7,9} = {1,0,1,0} mod 3
d = {2,6} = {2,0} mod 3
e = 5 = 2 mod 3
f = {4,8} = {1,2} mod 3
g = {1,3,7,9} = {1,0,1,0} mod 3
h = {2,6} = {2,0} mod 3
i doesn't matter since it's determined by the rest

7. abc=0 mod 3 & e=2 mod 3 & #6 --> def={258,654} for abcdef to be divisible by 6 (i.e. since e=2 mod 3, we must add even digits d&f that sum up to 3 or 6 which is zero modulo three)

By #7 & #5, we have four possible patterns:
(1) a4c25816i
(2) a4c25896i
(3) a8c65432i
(4) a8c65472i

8. If b=4, which is 1 mod 3, then to make abc=0 mod 3, a&c must be {1,7} in some order. This rules out pattern (1) as a possible solution since it has g=1. So we must test the first seven digits of the two permutations of pattern (2)--1472589 & 7412589 to see if either is divisible by 7. Neither is. So pattern (2) is ruled out.

So b=8 and the solutions must be of the form of pattern (3) or (4). There remain only eight possible solutions for the remaining digits a,c & i using the unused odd numbers:
189654327
789654321
987654321
981654327
183654729
189654723
381654729
981654723
Chop off the last two digits of each and test them for divisibility by 7--only the number 3816547 works.
So 381654729 is the solution. As mentioned before, there's no need to test for divisibility by 9, since the sum of the digits 1--9=45 which is a multiple of 9 so abcdefghi=0 mod 9.

### Finding the nine - solution

Granted that singingbanana's solution is the bare-bones needed.

Hand calcs can be reduced somewhat by observing that the progressive divisibility rule forces every second digit ( b d f h ) to be even. Corollary: the remaining five digits must be odd.

The modular 8 formula, (4f+2g+h)|8, can be simplified to (2g+h)|8 since, knowing f is even, 4f|8, and the f term drops out.

[Notation used here:( M)|N reads M is divisible by N. Equivalently (M) mod N = 0.]

The six term mod 6 formula can also be efficiently replaced by observing that any number divisible by 6 must also be divisible by 6's factors, 2 & 3. Again knowing f is even, the divisible by 2 constraint is met. The (a+b+c) terms are already defined to be divisible by 3, so the formula for 6 can be (d+e+f)|3.

The corollary for odds is useful when dealing with 4 & 8.

### Finding the nine (ten?)

This problem may be trivially extended to ten digits (including 0).
Zero will necessarily fall in the rightmost ( j ) position and the remainder of the problem is the nine digit one.