views:

697

answers:

3

Hi StackOverflow, Although it is not very programming related but I think SO could be of some assistance:

A zeroless pandigital number of base 10 is a number with all the 
distinct digits 1,2,3,4,5,6,7,8,9. 
For example, the first zeroless pandigital number of base 10 is 123456789.
Find a zeroless pandigital number of base 10 such that the numbers up to the nth 
digit is divisible by n i.e. the number formed by 1st, 2nd and 3rd digit 
is divisible by 3, the number formed by 1 to 6 digits is divisible by 6 
and so on.

I started with thinking as assuming the no. to be "abcdefghi" and stating that a can be any number between "1-9" b can be only the even ones, e is surely 5 and so on.

But I am not able to find how to go from here.

Any help/or better method will be appreciated

+5  A: 

Why are all the answers in the comments? I hope I'm not breaking some sort of etiquette I don't know about by posting an answer.

(b, d, f, h) have to be the even numbers (2, 4, 6, 8) in some order, e must be 5, so (a, c, g, i) have to be the numbers (1, 3, 7, 9) in some order. Once you've made these observations, there are only 4!*4!=576 possibilities, so check them all.

Anton Geraschenko
Am I the only person who shouts the number when they see a factorial? I hope not.
Andy Mikula
You're not alone. Depending on the company I'm in, I sometimes say "FOUR times FOUR equals five seventy six."
Anton Geraschenko
+1  A: 

The two-digit number cd (odd-even) should be divisible by 4 and the three digit number fgh(even-odd-even) should be divisible by 8.

Thus, considering the possibilities, d have to be 2 or 6, and h have to be 4, 2 or 6

This may help to reduce the number of possibilities.

Panpan
+2  A: 

Many ways to reduce the number of possibilities, or at least reduce the calculations expended.

b must be even.

(a + b + c) must be divisible by 3.

d must be even, but also (2c+d) must be divisible by 4.

e must be 5 or zero, and since 0 is not an option in a pandigital number that does not include 0, then e must be 5.

f must be even. But also, (a + b + c + d + e + f) must be divisible by 3. Since we already know that (a + b + c) is divisible by 3, then this tells us that (d + e + f) must be divisible by 3.

(a -2b -3c - d + 2e + 3f + g) must be divisible by 7.

h must be even, but also for divisibility by 8, we need only check that (4f+2g+h) is so divisible.

Since b, d, f, and h must all be even digits, then a,c,e,g,i must be only odd digits.

Finally, ALL 9 digit pandigital numbers that do not include 0 are divisible by 9. So no tests need be done for that at all!

woodchips