Palindrome Subtraction

392 Views Asked by At

A palindrome number is a number that is inverted, but the number remains the same. A four-digit palindrome number is 6226. Suppose, you subtract another four-digit palindrome number from such a four-digit palindrome. Subtraction is also a four-digit palindrome number. For how many four-digit palindrome numbers can that happen?

Here is how I tried:

I am assuming that for all 4-digit palindromes there exists another four four digit palindrome so that their subtraction is also a palindrome(except the smallest one i.e 1001)

Such as 9889-2002 = 7887, 4774-3223 = 1551 and so on.

There are total 90, 4-digit palindromes. As my assumption the answer should be 89 as(90-1). But I am getting the wrong answer, I don't know why....

2

There are 2 best solutions below

0
On

Well, first, lets find all of them.

1001

1111

1221

1331

1441

1551

1661

1771

1881

1991

And it repeats, with the first and last ones incremented by one.

Now, there were 10 numbers up there. Next,

1111

2222

3333

4444

5555

6666

7777

8888

9999

We have 9 choices for the first and last number. Therefore, there are 90 4 digit palindromes. We will exclude 0000, because I think you do not want that in our calculation. So, now, time for subtraction.

every one of them that has 1 in the front has none. every one of them that has 2 in the front has at least one palindrome that works:

2002-1001=1001

2112-1111=1001

2222-1221=1001

etc...

Every one of them that has 3 in front has at least 2 palindromes that work,

Every one of them that has 4 in front has at least 2 palindromes that work, etc...

so, the answer is 80, because every one of them has at least 1, except the 10 numbers that have 1 in front.

90-10=80, so there's your answer.

0
On

A four digit palindrome equals $1001a + 110b$, where $1 \leq a \leq 9$ and $0 \leq b \leq 9$. The difference between two palindromes is $1001(a-a’) + 110(b-b’)$. This is itself a palindrome if $a > a’$ (otherwise it’s only three digits, or negative), and $b \geq b’$ (otherwise the first and last digit are different).