# How many $7$ digits number can be made?

How many $7$ digits number can be made with $1,2,3,4,5,6,7$ so that they are divisible by $11$? (Repetition is not allowed.)

I know the divisibility rule of $11$, so the main problem is counting.

-
A simple Ruby solution: (1..7).to_a.permutation.count { |p| p.map(&:to_s).join.to_i % 11 == 0 } – Jacopo Notarstefano Feb 3 '14 at 3:21
@JacopoNotarstefano Did you get 576? – qwr Feb 3 '14 at 4:02
@qwr Yes, my solution returns 576. – Jacopo Notarstefano Feb 3 '14 at 4:04
@Jacopo In fact, I wrote a short program to verify too, in Python. – qwr Feb 3 '14 at 4:06
@JacopoNotarstefano and qwr This is math.stackexchange.com... MATH – YoYoYonnY Mar 14 at 21:35

Hint: work out a step by step procedure for choosing a number of the required type. Think of the number as $ABABABA$. Since all the digits add up to ... , the divisibility-by-$11$ rule says that all the $B$s must add up to ... (fill in the dots for yourself).

(1) First choose the three digits $B$ so that they add up to ... - there are not many possibilities and they are easy to count by trial and error.

(2) There is now only one choice for the $A$s, they are just the leftover numbers.

(3) Decide on an order for the $B$s.

(4) Decide on an order for the $A$s.

Work out the number of ways of doing steps $1,3$ and $4$ - there is only one way to do step $2$ so it doesn't matter - then combine them to get your final answer.

Good luck!

Update. As pointed out by @chubakueno, there is "in principle" more than one option for the sum of the $B$s. However only one of these options can be made the sum of three numbers from $1,2,3,4,5,6,7$.

-
There are two options for the sum of $B$(immediatly, it is then eliminated) – chubakueno Feb 3 '14 at 3:11
Actually there are three options, but as you point out, all but one are immediately eliminated. Thanks for the comment, will update my answer. – David Feb 3 '14 at 3:16
Glad to contribute! – chubakueno Feb 3 '14 at 3:23

If your number is $\overline{abcdefg}$, then $(b+d+f) - (a + c + e+g) = 0 \pmod{11}$.

The difference is $0$ (I don't think $11$ or $-11$ is possible, $-11$ isn't possible because of parity).

For $0$ you can try the solutions for $14-14$, any other combination ends up with the left side too large or small.

$(b+d+f)$ is one of these 4 combinations: $(2, 5, 7), \ (3, 5,6), \ (3,7,4), \ (1,7,6)$. Multiply 4 by how many orderings of 3 digits exist, then multiply by how many orderings of the last 4 digits exist $(4 \times 3! \times 4!)$

There are exactly 576 solutions.

-