Hello guys, I need some help...

How many 5-digit numbers that consist only of digits 1, 2 and 3 are divisible by 6?

Thanks in advance(Happy)

Printable View

- Sep 2nd 2011, 09:04 AMmarkjonathan5digit numbers divisble by 6
Hello guys, I need some help...

How many 5-digit numbers that consist only of digits 1, 2 and 3 are divisible by 6?

Thanks in advance(Happy) - Sep 2nd 2011, 09:48 AMSorobanRe: 5digit numbers divisble by 6
Hello, markjonathan!

Quote:

How many 5-digit numbers that consist only of digits 1, 2 and 3 are divisible by 6?

There is no neat formula for this problem.

I had to use brute-force Listing.

To be divisible by 2, the number must be even; it must end with 2.

To be divisible by 3, the digit-sum of the number must be a multiple of 3.

I found only five cases (and their permutations).

. .

Did I miss any?

- Sep 2nd 2011, 10:08 AMemakarovRe: 5digit numbers divisble by 6
The last digit must be 2 (why?). The sum of the first four digits must give the remainder 1 when divided by 3 (why?). Since that sum is between 4 and 12, it has to be 4, 7, or 10.

We need to find the number of tuples <a1, a2, a3, a4> such that a1 + a2 + a3 + a4 = 4, or 7, or 10. If there were no restrictions on the maximum of the tuple elements, then we could use the Stars and bars theorem. However, in this case it is probably easier to calculate the number by hand.

One way to do this is using the methods of dynamic programming. Consider the following table

Columns correspond to sums and rows correspond to the numbers of terms in sums. The cell in row and column is the number of different tuples such that . Some of the cells are easy to fill. Note that each value in the middle of the table is the sum of three values in the row above and immediately to the left, i.e., if is the value in row , column , then (why?). This allows filling the table in a systematic way. The answer to the problem is . I got the same answer as Soroban.