On finding all positive integers $a,b$ such that $b\pm a$ and $ab$ are palindromic
Wang Pok Lo, Yuval Paz

TL;DR
This paper characterizes all positive integer solutions where the sums or differences of the pair and their product are palindromes, providing explicit formulas and finite solutions.
Contribution
It completely classifies solutions for the palindromic sum/difference and product conditions, extending previous partial results.
Findings
Solutions for $a+b$ and $ab$ are explicitly listed.
Solutions for $b-a$ and $ab$ are given in parametric form.
Finite and infinite families of solutions are identified.
Abstract
It is proven that the only integer solutions such that and are palindromic are , and , and in a similar fashion, and are only palindromic at , , and for . Note without loss of generality.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Combinatorial Mathematics · graph theory and CDMA systems · Commutative Algebra and Its Applications
Abstract
It is proven that the only integer solutions such that and are palindromic are , and , and in a similar fashion, and are only palindromic at , , and for . Note without loss of generality.
On finding all positive integers such that and are palindromic
Wang Pok Lo, Yuval Paz
1 Introduction
The challenge to determine all positive integers such that and are palindromic has been 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 Stack Exchange where a user Michael Lugo [4] conjectured the same as Nandor. In this paper, we will prove their claims, and will also generalise this to the case where and are palindromic.
Definition:
Two integers are palindromic if the digits of one integer are the same as the reverse of the digits of the other, and if they both have the same number of digits.
That is, if one integer has digit representation and the other integer has digit representation , then they are palindromic if and only if
[TABLE]
Furthermore, but . This is so that the the first and last digits of and are not zero; otherwise, they would not have the same number of digits.
2 When and are palindromic
2.1 Formulating the problem
Without loss of generality assume that . Then and this must be less than . Hence .
For , let have the above digit representation, and let
[TABLE]
[TABLE]
Substituting from (1) into (2), we get
[TABLE]
Note that to preserve the same number of digits in each expression, , except for extreme cases highlighted in 2.3.
2.2 Finding the solutions
In this section it will be assumed that . Exceptions to this are also discussed in 2.3.
2.2.1 Solutions when
If , we can immediately solve the equation so is a trivial solution.
From (3), the equation becomes
[TABLE]
Clearly is even, and since , . If is the former, then so the first digit of is or . If , then so the last digit of must be which is a contradiction. Similarly, if , then so the last digit of must be , again, a contradiction. Therefore , meaning that starts with either . If then the last digit of is contradicting the fact that the first digit of is . Hence .
Dividing equation (4) by , the RHS is still even, so to fulfill that on the LHS, we must have that is even since all other terms on that side have at least one even factor. Since is odd, so is . Notice that , implying that there is carrying. This narrows down to either being , or .
If , then ends in the digits so must end in the digits or , implying that . However the second digit of is which is a contradiction. Similarly, if , then ends in the digits so must end in the digits or , implying that . However the second digit of is which is a contradiction. Finally, if , then ends in the digits so must end in the digits or , implying that . However the second digit of is which forces .
We have now arrived at and so . Again, we previously showed that is odd so is also odd. This is a cycle, so the only solutions when are which can be generalised to for .
2.2.2 Solutions when
In this section, equation (3) will be used for . That said, the cases will firstly be considered. Of course, gives no integer solutions so this eliminates the first one. If , equation (3) can be modified to give which is a standard Diophantine equation. Solving using the Euclidean Algorithm gives the general solution for an integer . But since , the only possible solution is when , so .
For , we have
[TABLE]
so is a multiple of . As , is restricted to .
If , divides which is impossible.
If , divides . This can be achieved only if , so starts with . Since the first digit of is , this indicates carrying, and in particular, that . If , ends in so ends in . This means that ends in and in turn, ends in . A contradiction arises as . If , ends in so ends in . This means that ends in and in turn, starts with . However this is impossible as . If , ends in so ends in . This means that ends in and in turn, starts with . Again this is contradictory since . Finally, if , ends in so ends in . This means that ends in and in turn, starts with which is impossible as . No solutions exist in this category.
If , divides . This can be achieved only if . Now only since carrying will increase the number of digits so immediately there is a contradiction. Therefore the only solution when is .
2.2.3 Solutions when
If then it is easy to show that no solutions exist for .
For , and we have that
[TABLE]
and clearly must be even to keep the parities consistent on both sides of the equation. Thus if , including carrying leading to . However, ends in respectively, not , which is a contradiction.
Similarly, for , and we have that
[TABLE]
but the LHS is not divisible by . This is again a contradiction.
2.2.4 Solutions when
When , so that so equation (3) becomes
[TABLE]
Now for , every term on the LHS is divisible by except so must be divisible by . This is a contradiction as must be a single digit and cannot be zero. The case where trivially gives no solutions and if , this requires the solution of the Diophantine equation , but the RHS is not divisible by . Hence no solutions exist and this completes .
Similarly, when , so
[TABLE]
For , every term on the LHS is even except so must be even. This means that is also even which is a contradiction. The case where trivially also gives no solutions and this case where requires the solution of the Diophantine equation , which is . As , the solution occurs when , so , implying that . Hence the only solution when is .
2.2.5 Solutions for the remaining
If is even, so is the RHS of (3). The LHS is also even as and are divisible by , except for the term . This means that is even. However, for even , we must set so that which is again a contradiction. If is odd; that is, , then clearly so all that is left is to check the extreme cases in the next section, where, for example, so that and have the same number of digits.
2.3 Checking the extreme cases
2.3.1 When
There were instances in 2.2 where it was assumed that . While this may be true for the majority of the values of , there are still some exceptions. For example, consider the case . If or then becomes not . However, by inspection it is apparent that and are not palindromic for these , since starts with but ends in or . Similarly, for the other five values of , we can check from to - since here, , but this yields no solutions either for all .
2.3.2 When
For these values of , so that and have the same number of digits. This means that we need only check from to and it can be easily verified (by comparing the first and last digits of each of and ) that no solutions exist here either.
3 When and are palindromic
3.1 Formulating the problem
This is very similar to section 2.1. The LHS of equation (1) in 2.1 will be replaced by but the rest of (1) and (2) remain the same. We get a near equivalent equation to (3); the only difference is due to the negative sign on the RHS:
[TABLE]
Note that ; otherwise, will have at least one more digit than as subtraction of a positive integer cannot increase the value of the expression. Again, the criterion (bar exceptions) that still holds.
3.2 Finding the solutions
As in 2.2, assume that in this section.
3.2.1 Solutions when
We will start with . We have two cases: and , as ends in . Of course, is trivially false, and implies that has more digits than . Both cases lead to contradictions, so there are no solutions.
We will now consider , first assuming we get , and this implies no solutions. Now we can apply (5) and get:
[TABLE]
Therefore is even, and to keep we also get . Multiplying by we get (which is the last digit of ) and we need only consider the carrying of because beyond that we will get a new digit. Now or , and multiplying the possible last digits by we get for the former and in the latter. Thus, if solutions exists, and .
This gives ; in other words, there is a carrying of from , so we get two possible values: .
If then ends with , dividing by yields , which contradicts the fact that .
If then ends with which is not divisible by so we have another contradiction. So for there are no solutions.
For , gives the equation which yields no results, and if , we can start by noticing that because
[TABLE]
If , is either or , but cannot be as ends in [math]. Thus , but ends in , which is a contradiction.
If , is or , but we know that ends in . Hence ends in either or , so ends with or which is . Now the only common number between and is , so . It is easy to see that is not a solution. So the possible values of are .
If then ends with where . This is a contradiction as for a positive integer we have ends in where is odd.
If then , which means that ends in or , so which is a contradiction to the fact that starts with . We are just left with ; if then , and also means that . Hence or , but does not end in so .
Claim:
Let . Then implies that .
Proof:
To prove this claim it will be shown that is not a solution, and indeed there exists the digit in but not in .
If is not a solution, there exists more digits, namely , that are not in the or , so we need to check .
For even we get an easy contradiction just like at the start: for an even digit ,
, but this is impossible as the last has a carrying which makes the next digit odd, and is even.
For we get that means ends in or and just like we did in the case of , it is a contradiction.
This forces , so , and . If we get in the place where there should be , so . We are done, because and the number of digits is ever growing (infinite), but every integer is finite, so there are no solutions.
3.2.2 Solutions when
From (5), we get that when , is even, but if then , so for there are no solutions.
For we get , and . If then so , but is a contradiction. For we get , then ends in 5 and not , again, a contradiction. Lastly, if then , so ends in . So there are no solutions. For we have and , so and ends in and not in , so again no solutions.
3.2.3 Solutions when
For , it is possible to solve the respective Diophantine equations, and no solutions exist when . When , the Diophantine equation becomes
[TABLE]
and the general solutions are for integers . Since , there are only nine cases to cover. For , and for , . However, when , and so is the only solution for .
For the rest of this section, . Firstly, we know that . Plugging and subtracting one from both sides of (5), the equation becomes
[TABLE]
and it can be seen that divides . However, if then is divisible by which is impossible as is a single-digit positive integer. If this forces , so (and hence ) begins with and begins with due to their palindromicity. This is contradictory since , so the only case left is .
If this forces since must divide . Now starts with and starts with so there is a carrying of from the second digit to the first digit - implying that . If , and . This forces since so starts with . We reach a contradiction as . This leaves us with .
3.2.3.1 When
If , and since there is a carrying of from the third digit, . If then since . Thus starts with and with which is a contradiction as . Similarly, if then since . Thus starts with and with which is again a contradiction as .
If , since . Thus starts with and with so there is a carrying of from the fourth digit. This implies that .
If , which forces as . Hence starts with which is contradictory since . If , which forces as . Hence starts with which is contradictory yet again since . In a similar argument, it can be shown that . In the next five paragraphs we will demonstrate that a pattern shows up.
Suppose that has seven digits; that is, where is a digit from [math] to . If this is multiplied by , . But starts with due to palindromicity, so or that . This forces since the last digit of is the same as itself. Hence is a solution.
Suppose that has eight digits; that is, where are single digits. From similar reasoning to the above, we deduce that (concatenation, not multiplication of ) due to carrying, so . The general solution to this is for an integer , but it is impossible for to be positive and less than . No solutions exist.
Suppose that has nine digits; that is, . The Diophantine equation this time is with general solution . For , and for , respectively, so . No solutions exist.
Suppose that has ten digits; that is, . The Diophantine equation is and it can be verified from [1] that all solutions produced have at least one variable that is no less than . No solutions exist.
Now suppose that has eleven digits; that is, . The Diophantine equation is . Going through from to and solving this gives us that only provides one solution with all variables less than . The unique solution is so .
In particular, we have that for of any length greater than eleven, . But we have arrived at exactly the same situation as in (*). This means that the cycle repeats, and thus is equal to followed by blocks of . Formally, and for , and this completes .
3.2.3.2 When
It can be verified that for , no solutions exist. This can be done by employing linear Diophantine equations. From (6), since and ,
[TABLE]
Combining terms and dividing by gives (for )
[TABLE]
[TABLE]
This means that for , is divisible by ; in other words, . Hence and . In turn, it can be implied that as .
If , ends in forcing since which is a contradiction as starts with and starts with . If , ends in forcing since which is contradictory as starts with and starts with . Furthermore, if , ends in forcing since which is again a contradiction as starts with and starts with . There is no contradiction when because works so we can continue down this route.
We are now left with so again, . If , starts with so as the fourth digit of . Now , and which is a contradiction as which is what we assumed for in this case. Similarly, if , starts with so as the fourth digit of . Now , and which is a contradiction as which is what we assumed for in this case. If , this forces since which in turn forces as . The contradiction is apparent. This means that as it turns out that if , using the same method as above. ()
Suppose that has nine digits; that is, just like in the previous subsection. Then which means that . The last digits of are and since is the only digit such that the last digit of is the same as , the only solution is .
Suppose that has ten digits; that is, . From similar reasoning to the above, we deduce that . This means that in algebraic terms, . This forces as , but this gives so no solutions exist.
Suppose that has eleven digits; that is, . The Diophantine equation this time is and it can be verified from [1] that there are no solutions such that .
Suppose that has twelve digits; that is, . The Diophantine equation is and similarly it can be verified from [1] that there are no solutions such that .
Now suppose that has thirteen digits; that is, . The Diophantine equation is . Going through from to and solving this gives us that only provides one solution with all variables less than . The unique solution is so .
In particular, we have that for of any length greater than thirteen, . But this is exactly where we had arrived at previously in (). This means that the cycle repeats, and thus is equal to followed by blocks of , followed by at the end. Formally, and for , and this completes .
4 References
HackMath, (2018). Integer Diophantine Equations Solver. Available from:
https://www.hackmath.net/en/calculator/integer-diophantine-equations-solver. [Accessed on 3 December 2018].
Nandor, M., (2009). The On-Line Encyclopedia of Integer Sequences. OEIS Foundation Inc. Available from: http://oeis.org/A166749. [Accessed 20 December 2018].
Quora, (2018). ”What are numbers whose sum is the reverse of their product?” Online posting. Available from:
https://www.quora.com/What-are-numbers-whose-sum-is-reverse-of-their-product. [Accessed 20 December 2018].
Lugo, M, (2018). A comment: When are and palindromic for integers ? Mathematics 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 Statistics, 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]
