Interchanging Digits!

How many four-digit positive integers divisible by 7 have the property that, when the first and last digits are interchanged, the result is a (not necessarily four-digit) positive integer divisible by 7?


The answer is 210.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Zee Ell
Jul 26, 2016

Relevant wiki: Application of Divisibility Rules

It is easy to see, that if two integers are both divisible by 7, then their difference is also divisible by 7.

a b c d d b c a = 1000 a + 100 b + 10 c + d ( 1000 d + 100 b + 10 c + a ) = 999 ( a d ) \overline{abcd} - \overline {dbca} = 1000a +100b+10c+d-(1000d+100b+10c+a)=999(a-d)

As 999 is not divisible by 7, therefore 7 ( a d ) 7 \mid (a-d) .

Now, we have the following cases:

\\

I. a d = 0 a = d a - d = 0 \iff a=d

As 7 1001 7 \mid 1001 ( and so are the multiples of 1001), therefore we have a solution if and only if the (not necessarily two digit, e.g. 00 or 07) number formed of the middle two digits ( b c \overline {bc} ) is divisible by 7.

We have 15 solutions ( b c = 7 k , k Z , 0 k 14 \overline {bc} = 7k, k \in \mathbb {Z} , 0 ≤ k ≤ 14 ) per value of digit a, and

9 × 15 = 135 solutions altogether in this case.

\\

II. a - d = ±7

As a a \in {1,2,3,4,5,6,7,8,9} , the possible (a,d) values are (1,8), (8,1), (2,9), (9,2) and (7,0).

Since 1008, 8001, 2009, 9002 and 7000 are all divisible by 7, we have a solution (similarly to case I.) iff 7 b c 7 \mid \overline {bc}

This means, that we have 15 solutions per pair of (a,d) values and

5 × 15 = 75 solutions altogether in this case.

\\ Therefore, the total number of solutions is:

135 + 75 = 210 135 + 75 = \boxed {210}

Difficult by Kyere Daniel yikrosec H. O .D

Daniel Kyere - 4 years, 10 months ago
Antonio Antonio
Jul 26, 2016

Really its a BRILLIANT solution.

Priyanshu Mishra - 4 years, 10 months ago
Fletcher Mattox
Oct 11, 2020
1
2
3
4
5
6
7
8
9
count = 0
for n in range(1000, 10000):
    if n%7 == 0:
        d = list(str(n))
        d[0], d[3] = d[3], d[0]
        k = int(''.join(d))
        if k%7 == 0:
            count += 1
print(count)

1
210

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...