# Divisibility Puzzle

Yesterday a friend of mine gave me this puzzle to solve :

Find a number consisting of 9 digits in which each of the digits from 1 to 9 appears only once. This number should satisfy the following requirements:

• The number should be divisible by 9.
• If the right-most digit is removed, the remaining number should be divisible by 8.
• If the two right-most digits are removed, the remaining number should be divisible by 7.
• If the three right-most digits are removed, the remaining number should be divisible by 6.
• If the eight right-most digits are removed, the remaining number should be divisible by 1.

We sure can solve this using crazy mathematics, but I have a clever idea, let the computer solve it for us.

How about writing code to solve this .. FUN \m/

When you break down this problem , its basically which permutation of 123456789  satisfy the above conditions.

So All we have to do is loop through all the permutations and for every permutation check if it satisfies the above conditions.

I know its not ideal to go through all the n! permutations and find the number. But it WORKS and it gave me solution in seconds.