On finding all positive integers a,b such that b±a and ab are palindromic
aa r X i v : . [ m a t h . HO ] J a n On finding all positive integers a, b such that b ± a and ab arepalindromic Wang Pok Lo, Yuval Paz
Abstract
It is proven that the only integer solutions ( a, b ) such that a + b and ab are palindromicare (2 , · k − ,
24) and (9 , b − a and ab are only palindromicat ( a, b ) = (3 , · k +1) + 5247 P ki =0 i ), (3 ,
161 247 · k +7 + 5247 P ki =0 i +3 + 387),(3 , ,
161 247 387) for k = 0 , , , · · · . Note a ≤ b without loss of generality. The challenge to determine all positive integers a, b such that b + a and ab are palindromic hasbeen explored by a few people, but none has yet provided a rigorous proof of all the solutions.In 2009, the conjectured solutions were posted on OEIS by Mark Nandor [2]. More recently,there was a question on Quora [3] asking this, and we have even done so on Mathematics StackExchange where a user Michael Lugo [4] conjectured the same as Nandor. In this paper, wewill prove their claims, and will also generalise this to the case where b − a and ab are palindromic. Definition : Two integers are palindromic if the digits of one integer are the same as the reverse of thedigits of the other, and if they both have the same number of digits.
That is, if one integer a has digit representation a n a n − · · · a and the other integer b has digitrepresentation b n b n − · · · b , then they are palindromic if and only if a = b n , a = a n − , · · · , a n − = b , a n = b Furthermore, a , · · · , a n − , b , · · · , b n − ∈ { , , , · · · , } but a , a n , b , b n ∈ { , , · · · , } . Thisis so that the the first and last digits of a and b are not zero; otherwise, they would not havethe same number of digits. a + b and ab are palindromic Without loss of generality assume that a ≤ b . Then aba + b > ab b = a and this must be less than10. Hence a < n >
1, let b have the above digit representation, and let a + b = c n c n − · · · c c = 10 n − c n + 10 n − c n − + · · · + 10 c + c (1) ab = c c · · · c n − c n = 10 n − c + 10 n − c + · · · + 10 c n − + c n (2)Substituting b from (1) into (2), we get( a · n − − c n + ( a · n − − c n − + · · · + (10 a − n − ) c + ( a − n − ) c = a (3)Note that to preserve the same number of digits in each expression, ac n <
10, except for extremecases highlighted in § In this section it will be assumed that c n = b n . Exceptions to this are also discussed in § .2.1 Solutions when a = 2If n = 1, we can immediately solve the equation 2+ b = 2 b = ⇒ b = 2 so (2 ,
2) is a trivial solution.From (3), the equation becomes(2 · n − − c n + (2 · n − − c n − + · · · + (20 − n − ) c + (2 − n − ) c = 4 (4)Clearly c n is even, and since 2 · > c n = 2 ,
4. If c n is the former, then b n = 2 so the first digitof 2 b is c = 4 or 5. If c = 4, then b = c − b must be 4 = c n whichis a contradiction. Similarly, if c = 5, then b = 3 so the last digit of 2 b must be 6 = c n , again,a contradiction. Therefore c n = 4, meaning that 2 b starts with either c = 8 , ⇒ b = 6 , b = 6 then the last digit of 2 b is 2 contradicting the fact that the first digit of b is 4. Hence b = 7 = ⇒ c = 9.Dividing equation (4) by 2, the RHS is still even, so to fulfill that on the LHS, we must havethat − c n − + c is even since all other terms on that side have at least one even factor. Since c is odd, so is c n − . Notice that c = 2 c n + 1, implying that there is carrying. This narrows c n − down to either being 5, 7 or 9.If c n − = 5, then 2 b ends in the digits 54 so b must end in the digits 27 or 77, implyingthat c = 2 ,
7. However the second digit of 2 b is c = 2 c n − = 0 , c n − = 7, then 2 b ends in the digits 74 so b must end in the digits 37 or 87, implyingthat c = 3 ,
8. However the second digit of 2 b is c = 2 c n − = 4 , c n − = 9, then 2 b ends in the digits 94 so b must end in the digits 47 or 97, implyingthat c = 4 ,
9. However the second digit of 2 b is c = 2 c n − = 8 , c = 9.We have now arrived at b = 49 · · ·
97 = ⇒ b = 49 · · ·
99 and 2 b = 99 · · ·
94 so c ≥ c is odd so c n − is also odd. This is a cycle, so the onlysolutions when a = 2 are b = 2 , , , , · · · which can be generalised to 5 · k − k = 0 , , , · · · . a = 3In this section, equation (3) will be used for n >
2. That said, the cases n = 1 , b = 3 b gives no integer solutions so this eliminates thefirst one. If n = 2, equation (3) can be modified to give 29 c − c = 9 which is a stan-dard Diophantine equation. Solving using the Euclidean Algorithm gives the general solution( c , c ) = (9 + 7 t,
36 + 29 t ) for an integer t . But since c , c <
10, the only possible solution iswhen t = −
1, so ( c , c ) = (2 ,
7) = ⇒ b = 24.For n >
2, we have1 + (3 · n − − c n + (3 · n − − c n − + · · · + (30 − n − ) c + (3 − n − ) c = 10so 1 − c n + 3 c is a multiple of 10. As 3 c n < c n is restricted to 1 , , c n = 1, 10 divides 1 − c which is impossible.If c n = 2, 10 divides 3 c −
1. This can be achieved only if c = 7, so 3 b starts with 7. Sincethe first digit of 3 + b is 2, this indicates carrying, and in particular, that c n − = 3 , , ,
6. If c n − = 3, 3 b ends in 32 so b ends in 44. This means that b + 3 ends in 47 and in turn, 3 b ends in74. A contradiction arises as 3 · <
74. If c n − = 4, 3 b ends in 42 so b ends in 14. This meansthat b + 3 ends in 17 and in turn, 3 b starts with 71. However this is impossible as 3 · >
71. If c n − = 5, 3 b ends in 52 so b ends in 84. This means that b + 3 ends in 87 and in turn, 3 b startswith 78. Again this is contradictory since 3 · <
78. Finally, if c n − = 6, 3 b ends in 62 so b b + 3 ends in 57 and in turn, 3 b starts with 75 which is impossibleas 3 · >
75. No solutions exist in this category.If c n = 3, 10 divides 3 c −
2. This can be achieved only if c = 4. Now 3 c n = 9 = c only since carrying will increase the number of digits so immediately there is a contradiction.Therefore the only solution when a = 3 is b = 24. a = 4 , n = 1 then it is easy to show that no solutions exist for a = 4 , a = 4, c n = 1 , · n − − c n + (4 · n − − c n − + · · · + (40 − n − ) c + (4 − n − ) c = 16and clearly c n must be even to keep the parities consistent on both sides of the equation. Thusif c n = 2, c = 8 , b = 4 ,
5. However, 4 b ends in 6 , c n = 2, which is a contradiction.Similarly, for a = 5, c n = 1 and we have that(5 · n − −
1) + (5 · n − − c n − + · · · + (50 − n − ) c + (5 − n − ) c = 25but the LHS is not divisible by 5. This is again a contradiction. a = 7 , a = 7, c n = 1 so that ac n <
10 so equation (3) becomes(7 · n − ) + (7 · n − − c n − + · · · + (70 − n − ) c + (7 − n − ) c = 50Now for n >
2, every term on the LHS is divisible by 10 except 7 c so c must be divisible by 10.This is a contradiction as c must be a single digit and cannot be zero. The case where n = 1trivially gives no solutions and if n = 2, this requires the solution of the Diophantine equation(7 · − c − (7 − c = 7 = ⇒ c − c ) = 49, but the RHS is not divisible by 3. Henceno solutions exist and this completes a = 7.Similarly, when a = 9, c n = 1 so(9 · n − ) + (9 · n − − c n − + · · · + (90 − n − ) c + (9 − n − ) c = 82For n >
2, every term on the LHS is even except 9 c so c must be even. This means that c n isalso even which is a contradiction. The case where n = 1 trivially also gives no solutions and thiscase where n = 2 requires the solution of the Diophantine equation (9 · − c + (9 − c =9 = ⇒ c − c = 81, which is ( c , c ) = ( t, −
81 + 89 t ). As 0 < c , c <
10, the solution occurswhen t = 1, so ( c , c ) = (1 , b = 18 − a = 9 is b = 9. a If a is even, so is the RHS of (3). The LHS is also even as a and 10 are divisible by 2, exceptfor the term − c n . This means that c n is even. However, for even a >
5, we must set c n = 1 sothat ac n <
10 which is again a contradiction. If a is odd; that is, a = 11 , , · · · ,
19, then clearly ac n >
10 so all that is left is to check the extreme cases in the next section, where, for example, b = 10 n − a so that a + b and ab have the same number of digits.3 .3 Checking the extreme cases a = 2 , , , , , § c n = b n . While this may be true forthe majority of the values of b , there are still some exceptions. For example, consider the case a = 2. If b = 19 · · ·
98 or 19 · · ·
99 then c n becomes 2 not 1. However, by inspection it is apparentthat 2 + b and 2 b are not palindromic for these b , since 2 + b starts with 2 but 2 b ends in 6or 8. Similarly, for the other five values of a , we can check from b = 10 n − ( b n + 1) − a to10 n − ( b n + 1) − c n = b n + 1, but this yields no solutions either for all n > a = 11 , , , , a , b n = 9 so that a + b and ab have the same number of digits. This meansthat we need only check from b = 10 n − a to 10 n − a + b and ab ) that no solutions exist here either. b − a and ab are palindromic This is very similar to section 2.1. The LHS of equation (1) in § b − a but the rest of (1) and (2) remain the same. We get a near equivalent equation to (3); the onlydifference is due to the negative sign on the RHS:( a · n − − c n + ( a · n − − c n − + · · · + (10 a − n − ) c + ( a − n − ) c = − a (5)Note that a <
10; otherwise, ab will have at least one more digit than b − a as subtraction of apositive integer cannot increase the value of the expression. Again, the criterion (bar exceptions)that ac n <
10 still holds.
As in § c n = b n in this section. a = 2 , , a = 5. We have two cases: c n = 0 and c n = 5, as 5 b ends in c n . Of course, c n = 0 is trivially false, and c n = 5 implies that 5 b has more digits than b −
5. Both cases leadto contradictions, so there are no solutions.We will now consider a = 4, first assuming n = 1 we get b − b , and this implies nosolutions. Now we can apply (5) and get:(4 · n − − c n + (4 · n − − c n − + · · · + (40 − n − ) c + (4 − n − ) c = − c n is even, and to keep ac n <
10 we also get c n < ⇒ c n = 2. Multiplying by 4 weget c = 8 , b −
4) and we need only consider the carrying of 1 becausebeyond that we will get a new digit. Now b = 2 · · · · · · b = 2 · · · · · ·
3, and multiplying thepossible last digits by 4 we get c n = 8 for the former and c n = 2 in the latter. Thus, if solutionsexists, c n = 2 and c = 3.This gives b = 2 · · · · · · ⇒ b − · · · · · · ⇒ b = 9 · · · · · ·
2; in other words, there is acarrying of 1 from c n − , so we get two possible values: c n − = 3 , c n c n − = 23 then 4 b ends with 32, dividing 32 by 4 yields b = 8, which contradicts the factthat b = 3.If c n c n − = 24 then 4 b ends with 42 which is not divisible by 4 so we have another contradiction.4o for a = 4 there are no solutions.For a = 2, n = 1 gives the equation 2 a = a − n ≥
2, wecan start by noticing that c n = 2 , · n − − c n + (2 · n − − c n − + · · · + (20 − n − ) c + (2 − n − ) c = 4If c n = 4, c is either 8 or 9, but c cannot be 8 as 8 + 2 ends in 0. Thus c = 9 = ⇒ b = 1,but 2 b ends in 4, which is a contradiction.If c n = 2, c is 4 or 5, but we know that 2 b ends in c n = 2. Hence b ends in either 1 or 6,so b − c . Now the only common number between 4 , , c = 4. It is easy to see that 24 + 2 = 26 is not a solution. So the possible values of c n − are0 , , , , c n − = 0 , , b ends with d d = 0 , ,
4. This is a contradiction as for apositive integer k we have 2 · ( k ·
10 + 6) ends in t t is odd.If c n − = 1 then b − · · · · · · ⇒ b = 4 · · · · · ·
12, which means that b ends in 06or 56, so c = 0 , b starts with 21. We are justleft with c n − = 3; if b − · · · · · · b = 4 · · · · · ·
32, and c n − = 3 also means that c = 6 ,
7. Hence b = 23 · · · · · ·
66 or b = 23 · · · · · ·
76, but 76 · c = 6. Claim:Let k = 3 · · · | {z } k times , k = 6 · · · | {z } k times . Then b = 2(3 k ) · · · k implies that b = 2(3 k +1 ) · · · k +1 . Proof:
To prove this claim it will be shown that b = 2(3 k )6 k is not a solution, and indeed thereexists the digit 7 in 2 b but not in b − k k is not a solution, there exists more digits, namely c n − k − , c k +1 , that are not in the3 k or 6 k , so we need to check c n − k − = 0 , , , , c n − k − we get an easy contradiction just like at the start: for an even digit d , b − k ) d · · · k − ⇒ b = 4(6 k − ) · · · d k
2, but this is impossible as the last 6 has acarrying which makes the next digit odd, and d is even.For c n − k − = 1 we get b − k )1 · · · k − ⇒ b = 4(6 k − ) · · · k b ends in 06 k − or 56 k − and just like we did in the case of c n − = 1, it is a contradiction.This forces c n − k − = 3, so b − k +1 ) · · · k − ⇒ b = 4(6 k − ) · · · k +1
2, and c n − k − = 3 = ⇒ c k +1 = 6 ,
7. If c k +1 = 7 we get 5 in the place where there should be 3,so c k +1 = 3. We are done, because 6 = 3 and the number of digits is ever growing (infinite), butevery integer is finite, so there are no solutions. (cid:3) a = 6 , , , a = 6 , c n is even, but if c n > ac n >
10, so for a = 6 , a = 7 we get c n = 1, and c = 7 , ,
9. If c = 7 then b = 1 · · · · · · b = 7 · · · · · · = 1 is a contradiction. For c = 8 we get b = 1 · · · · · ·
5, then 7 b ends in 5 and not 1,again, a contradiction. Lastly, if c = 9 then b = 1 · · · · · ·
6, so 7 b ends in 2 = 1. So there are nosolutions. For a = 9 we have c n = 1 and c = 9, so b = 1 · · · · · · b ends in 2 and not in 9,so again no solutions. 5 .2.3 Solutions when a = 3For n ≤
3, it is possible to solve the respective Diophantine equations, and no solutions existwhen n = 1 ,
2. When n = 3, the Diophantine equation becomes(3 · − c + (30 − c + (3 − c = − = ⇒ c + 20 c − c = − c , c , c ) = ( t, − − s + 259 t, s − t ) for integers s, t .Since c = t <
10, there are only nine cases to cover. For t = 1 , , , , , c ≥
10 and for t = 5 , c ≫
10. However, when t = 4, c = 4 and c = 1 so b − ⇒ b = 147 is theonly solution for n ≤ n >
3. Firstly, we know that c n = 1 , ,
3. Plugging a = 3 andsubtracting one from both sides of (5), the equation becomes − · n − − c n + (3 · n − − c n − + · · · + (30 − n − ) c + (3 − n − ) c = −
10 (6)and it can be seen that 10 divides − − c n + 3 c . However, if c n = 2 then 3( c −
1) is divisibleby 10 which is impossible as c is a single-digit positive integer. If c n = 3 this forces c = 8,so b − b ) begins with 3 and 3 b begins with 8 due to their palindromicity. This iscontradictory since 3 · >
8, so the only case left is c n = 1.If c n = 1 this forces c = 4 since 10 must divide 3 c −
2. Now b starts with 1 and 3 b starts with4 so there is a carrying of 1 from the second digit to the first digit - implying that c n − = 4 , , c n − = 5, b − · · · · · · ⇒ b = 15 · · · · · · b = 4 · · · · · ·
51. This forces c = 1 since17 · b starts with 41. We reach a contradiction as 15 · >
41. This leaves us with c n − = 4 , c n − = 4If c n − = 4, b = 14 · · · · · ·
47 = ⇒ b − · · · · · ·
44 = ⇒ b = 44 · · · · · ·
41 and since thereis a carrying of 2 from the third digit, c n − = 7 , ,
9. If c n − = 9 then b = 6 = c since647 · b starts with 149 and 3 b with 446 which is a contradiction as 149 · > c n − = 8 then b = 3 = 9 = c since 947 · b starts with 148 and 3 b with 449 which is again a contradiction as 148 · < c n − = 7, b = 2 = c since 247 · b starts with 147 and 3 b with 442 sothere is a carrying of 1 from the fourth digit. This implies that c n − = 4 , , c n − = 4, b = 1474 · · ·
247 = ⇒ b = 442 · · · c = 8 as 8247 · b starts with 4428 which is contradictory since 1474 · c n − = 6, b = 1476 · · ·
247 = ⇒ b = 442 · · · c = 2 as 2247 · b startswith 4422 which is contradictory yet again since 1476 · c n − = 5 = c ( ∗ ). In the next five paragraphs we will demonstrate that a patternshows up.Suppose that b has seven digits; that is, b = 147 x
247 where x is a digit from 0 to 9. Ifthis is multiplied by 3, 3 b = 441(3 x )741. But 3 b starts with 442 due to palindromicity, so3 x = 12 , ,
18 or that x = 4 , ,
6. This forces x = 5 since the last digit of 3 x is the same as x itself. Hence b = 1475247 is a solution.Suppose that b has eight digits; that is, b = 147 xy
247 where x, y are single digits. From similarreasoning to the above, we deduce that 3( xy ) = yx + 100 (concatenation, not multiplication of xy ) due to carrying, so 29 x − y = 100. The general solution to this is ( x, y ) = (100+7 t, t )for an integer t , but it is impossible for y to be positive and less than 10. No solutions exist.6uppose that b has nine digits; that is, b = 147 xyz x + 20 y − z = 100 with general solution ( x, y, z ) = (20 + 20 s − t, − − s + 259 t, t ).For t = 1 , , , x ≥
10 and for t = 2 , , , , s = 1 , , , , y ≫
10. Nosolutions exist.Suppose that b has ten digits; that is, b = 147 wxyz w +290 x − y − z = 10000 and it can be verified from [1] that all solutions produced have atleast one variable that is no less than 10. No solutions exist.Now suppose that b has eleven digits; that is, b = 147 vwxyz w + 200 x − y − z = 100000 − v . Going through v from 1 to 9 and solvingthis gives us that only v = 5 provides one solution with all variables less than 10. The uniquesolution is ( v, w, x, y, z ) = (5 , , , ,
5) so b = 14752475247.In particular, we have that for b of any length greater than eleven, b = 1475247 · · · b is equal to 147 followed by blocks of 5247. Formally, b = 147 · k +1) + 5247 P ki =0 i and 147 for k = 0 , , , · · · , and this completes c n − = 4. c n − = 6It can be verified that for n ≤
3, no solutions exist. This can be done by employing linearDiophantine equations. From (6), since c n = 1 and c = 4, − · n − + (3 · n − − c n − + · · · + (30 − n − ) c + 12 − · n − = − n > − n − + (3 · n − − c n − + · · · + (3 − n − ) c = − − − n − + (3 · n − − c n − + · · · + (3 − n − ) c = − c n − = 6, − − c is divisible by 10; in other words, c = 8. Hence b − · · · · · ·
84 = ⇒ b = 16 · · · · · ·
87 and 3 b = 48 · · · · · ·
61. In turn, it can be implied that c n − = 0 , , , · c n − = 0, 3 b ends in 061 forcing c = 6 since 684 · b starts with 160 and 3 b starts with 486. If c n − = 2, 3 b ends in 261 forcing c = 0 since84 · b starts with 162 and 3 b starts with 480. Furthermore,if c n − = 3, 3 b ends in 361 forcing c = 7 since 787 · b starts with 163 and 3 b starts with 487 < ·
3. There is no contradiction when c n − = 1because c = 3 works so we can continue down this route.We are now left with b = 161 · · · · · ·
387 = ⇒ b − · · · · · ·
384 = ⇒ b = 483 · · · · · ·
161 soagain, c n − = 0 , , ,
3. If c n − = 0, b starts with 1610 so c = 0 , , b .Now 0387 · · · , , = 0which is what we assumed for c n − in this case. Similarly, if c n − = 1, b starts with 1611 so c = 3 , , b . Now 3387 · · · , , = 1 which is what we assumed for c n − in this case. If c n − = 3,this forces c = 9 since 1613 · c n − = 8 as 9384 · b = 1612 · · · · · · c n − = 2, c = 7 using the same method as above. ( † )Suppose that b has nine digits; that is, b = 1612 x b = 4836(3 x + 2)2161 which means that 20 > x + 2 ≥
10 = ⇒ x + 2 = 11 , ,
17 = ⇒ x = 3 , ,
5. The last digits of 3 x + 2 are 1 , , x + 2 is the same as x , the only solution is b = 161247387.Suppose that b has ten digits; that is, b = 1612 xy xy ) + 2 = yx + 100. This means that in algebraic terms, 29 x − y = 98. Thisforces x = 7 as 29 x = 7( y + 14), but this gives y = 15 >
10 so no solutions exist.Suppose that b has eleven digits; that is, b = 1612 xyz x + 20 y − z = 998 and it can be verified from [1] that there are no solutions suchthat x, y, z < b has twelve digits; that is, b = 1612 wxyz w + 290 x − y − z = 9998 and similarly it can be verified from [1] that there are nosolutions such that w, x, y, z < b has thirteen digits; that is, b = 1612 vwxyz w + 200 x − y − z = 99998 − v . Going through v from 1 to 9 and solvingthis gives us that only v = 4 provides one solution with all variables less than 10. The uniquesolution is ( v, w, x, y, z ) = (4 , , , ,
4) so b = 161 247 5247 387.In particular, we have that for b of any length greater than thirteen, b = 161 247 5247 · · ·
387 = ⇒ b = 161 247 52 · · · † ). This meansthat the cycle repeats, and thus b is equal to 161247 followed by blocks of 5247, followed by387 at the end. Formally, b = 161247 · k +7 + 5247 P ki =0 i +3 + 387 and 161 247 387 for k = 0 , , , · · · , and this completes c n − = 6. [1] HackMath, (2018). Integer Diophantine Equations Solver . Available from: . [Ac-cessed on 3 December 2018].[2] Nandor, M., (2009).
The On-Line Encyclopedia of Integer Sequences . OEIS FoundationInc. Available from: http://oeis.org/A166749 . [Accessed 20 December 2018].[3] Quora, (2018). ”What are numbers whose sum is the reverse of their product?”
Onlineposting. Available from: . [Ac-cessed 20 December 2018].[4] Lugo, M, (2018). A comment:
When are a + b and ab palindromic for integers a, b ? Mathe-matics Stack Exchange, Stack Exchange Inc. Available from: https://math.stackexchange.com/q/2961866/471884 [Accessed 20 December 2018].
Affiliations
Wang Pok Lo, The University of Sheffield, School of Mathematics and Statis-tics, Hicks Building, Sheffield, S3 7RH, United Kingdom.
Email address: [email protected]
Yuval Paz, The Hebrew University of Jerusalem, Department of Mathematics,E. Safra, Jerusalem, Israel.
Email address: [email protected]@mail.huji.ac.il