
Anuvrat Singh Project Euler Badge
This was one of those questions that can be solved using a pen and paper. Problem 53 requires one to find all the 10-digit pandigital numbers which satisfy the following properties:
is divisible by 2
is divisible by 3
is divisible by 5
is divisible by 7
is divisible by 11
is divisible by 13
is divisible by 17
Just to reiterate, a pandigital number is one in which each digit occurs only once. This is how we proceed:
is divisible by 5
- This implies that
is either 0 or 5.
is divisible by 11
- This implies that
is a multiple of 11.
- If
were to be 0, it would mean that
or
, neither of which can be true given that the number we seek is pandigital.
- So we can assert that
.
- We need all the pairs of
and
satisfying
or
.
- Possible
pairs are (6,1), (7,2), (8,3), (9,4), (1,7), (2,8), (3,9)
is divisible by 7
- This essentially means that
is a multiple of 7. We already have the value for
and have narrowed down the possible values of
.
- Possible
tuples are (7,5,6,1), (3,5,7,2), (6,5,8,3), (2,5,9,4), (6,5,1,7) or (9,5,2,8).
is divisible by 13
- This implies that
is a multiple of 13. We have already identified the possible
pairs. We can get the possible
values now.
- Possible
tuples are (3,5,7,2,8), (6,5,8,3,2) or (9,5,2,8,6).
is divisible by 17
- This implies that
is a multiple of 17. Again using the possible values of the other two variables, we can narrow down the value of the third one.
So we now have the following tuples for the values of : (3,5,7,2,8,9) or (9,5,2,8,6,7).
is divisible by 2 tells us that
is even. So in the first case it can take the values 0,4,6 and in the second case the values 0,4.
Finally, using the last condition that is divisible by 3, we conclude that
in the first case can be either of 6,0 or 0,6 and in the second case is 0,9.
Thus we have the six possible numbers as: 1406357289, 1460357289, 4106357289, 4160357289, 1430952867 and 4130952867. And we are done! Sum of these 6 numbers is what the problem asked for.
Popularity: 4% [?]