Answers are grounded in this paper and cite their sources.
[11pt]{article}[margin=1in]{geometry}{amsmath, amssymb, amsthm}{hyperref} {theorem}{Theorem}*{remark}{Remark} {On the Compositeness of Differences Between Integers and Nearest Smaller Palindromes}{Tharun H K \\ [Hassan University, Hassan, karnataka, India \\ tharunhk35@gmail.com}{12/11/2026} {document} the Compositeness of Differences Between Integers and Nearest Smaller Palindromes {abstract}In this note, we study the difference between a multi-digit number in base $10$ and the largest palindrome smaller than it. Specifically, let d ≥ 3 and let N be a d-digit positive integer whose first and last digits differ by $5$. If P is the largest d-digit palindrome strictly less than N, we prove that the difference $N - P$ is always a composite number whenever $N - P > 5$. We also give simple examples to show why the conditions d ≥ 3 and P being the largest smaller palindrome are necessary.{abstract} {Introduction}Palindromic numbers---integers that read the same from left to right and right to left---have long been a topic of interest in elementary number theory {sequence}. Several well-known results examine how integers can be written as sums of palindromes (for instance, Banks {banks2016} showed that every positive integer is the sum of at most $49$ palindromes, later improved to three) as well as the gaps between consecutive palindromes. Here, we look at a simple property of the gap $N - P$ between a given d-digit integer N and the largest d-digit palindrome $P < N$. In general, the difference between a number and a smaller palindrome can easily be a prime number. However, if we fix the difference between the first and last digits of N to be $5$, the gap $N - P$ is forced to be composite whenever it exceeds $5$. In Section~{sec:main}, we prove this result, and in Section~{sec:remarks}, we show with counterexamples that none of our conditions can be dropped. {Main Result}{sec:main} {theorem}Let d ≥ 3 be an integer, and let N be a d-digit positive integer in base $10$ whose first and last digits differ by $5$. Let P be the largest d-digit palindrome strictly less than N. If $N - P > 5$, then $N - P$ is composite.{theorem} {proof}Let us write N in base $10$ as\[N = ∑ᵢ₌₁ᵈ a_i 10ᵈ⁻ⁱ,\]where a₁ ∈ \1, 2, , 9\, aᵢ ∈ \0, 1, , 9\ for 2 ≤ i ≤ d, and |a₁ - ad| = 5. First, we check that such a palindrome P always exists. The smallest d-digit palindrome is Pₘᵢₙ = 10ᵈ⁻¹ + 1.{itemize} If a₁ = 1, then |a₁ - ad| = 5 gives ad = 6, so N ≥ 10ᵈ⁻¹ + 6 > Pₘᵢₙ. If a₁ ≥ 2, then N ≥ 2 · 10ᵈ⁻¹ > 10ᵈ⁻¹ + 1 = Pₘᵢₙ.{itemize}Thus, there is always at least one d-digit palindrome strictly less than N, so the largest such palindrome P is well-defined. Let b₁ ∈ \1, 2, , 9\ be the first digit of P. Since P is a palindrome, its last digit is also b₁. Because $P < N$, we must have b₁ ≤ a₁. This gives us two cases. 1: b₁ = a₁.Here, N and P have the same first digit. Taking remainders modulo $10$, we get N ≡ ad 10 and P ≡ b₁ = a₁ 10. Subtracting the two gives\[N - P ≡ a_d - a_1 ≡ ± 5 ≡ 5 {10}.\]This means $N - P$ is divisible by $5$. Since we are given $N - P > 5$, $N - P$ is a multiple of $5$ strictly larger than $5$, and hence it must be composite. 2: b₁ < a₁.Consider the smallest d-digit palindrome starting with a₁, which is\[P_0 = a_1 · 10ᵈ⁻¹ + a_1.\]Since P is the largest d-digit palindrome less than N and b₁ < a₁, no palindrome starting with a₁ can be less than N. Therefore, N ≤ P₀. Moreover, since ad ≠ a₁, we have N ≠ P₀, which means N < P₀. Writing this out, we get\[a_1 · 10ᵈ⁻¹ + ∑ᵢ₌₂ᵈ⁻¹ a_i 10ᵈ⁻ⁱ + a_d < a_1 · 10ᵈ⁻¹ + a_1,\]which simplifies to\[∑ᵢ₌₂ᵈ⁻¹ a_i 10ᵈ⁻ⁱ + a_d < a_1 ≤ 9.\]Because all digits are non-negative, every middle digit must be zero (a₂ = a₃ = = ad-1 = 0) and ad < a₁. Since |a₁ - ad| = 5 and ad < a₁, we get ad = a₁ - 5, which is only possible when a₁ ≥ 5. Hence,\[N = a_1 · 10ᵈ⁻¹ + (a_1 - 5).\]Now, since a₁ ≥ 5, we have a₁ - 1 ≥ 4. The largest d-digit palindrome with first digit strictly less than a₁ is obtained by setting the outer digits to a₁ - 1 and all middle digits to $9$:\[P^* = (a_1 - 1)10ᵈ⁻¹ + ∑ᵢ₌₂ᵈ⁻¹ 9 · 10ᵈ⁻ⁱ + (a_1 - 1) = a_1 · 10ᵈ⁻¹ + a_1 - 11.\]Clearly, P^* < a₁ · 10ᵈ⁻¹ + a₁ - 5 = N, so P = P^*. Subtracting P from N gives\[N - P = (a_1 · 10ᵈ⁻¹ + a_1 - 5) - (a_1 · 10ᵈ⁻¹ + a_1 - 11) = 6,\]which is composite. In both cases, $N - P$ is composite. This completes the proof.{proof} {Remarks}{sec:remarks} {remark}[Why P must be the largest smaller palindrome]The theorem does not hold if we replace P with any smaller d-digit palindrome. For instance, take $d = 3$ and $N = 601$ (here $|6 - 1| = 5$). If we pick the smaller palindrome $P = 494$, we get $N - P = 601 - 494 = 107$, which is prime. Similarly, for $d = 4$, taking $N = 6001$ and $P = 4884$ gives $N - P = 1117$, which is also prime.{remark} {remark}[Why d ≥ 3 is required]When $d = 2$, the condition $N - P > 5$ never holds in Case 1 because there are no middle digits. Checking all $2$-digit numbers N = a₁ a₂̄ with |a₁ - a₂| = 5:{itemize} If a₂ = a₁ + 5, then N ∈ \16, 27, 38, 49\ and P ∈ \11, 22, 33, 44\, so $N - P = 5$ in every case. If a₂ = a₁ - 5, then N ∈ \50, 61, 72, 83, 94\ and P ∈ \44, 55, 66, 77, 88\, so $N - P = 6$ in every case.{itemize}Having d ≥ 3 allows middle digits to exist, so Case 1 can produce composite differences greater than $5$ (for example, $N = 136$ and $P = 121$ give $N - P = 15$).{remark} {thebibliography}{9} {banks2016}W.~D.~Banks, Every natural number is the sum of forty-nine palindromes, Integers 16 (2016), #A3. {sequence}N.~J.~A.~Sloane et al., The On-Line Encyclopedia of Integer Sequences, Sequence A002113 (Palindromes in base 10), {https://oeis.org}. {thebibliography} {document}
No takes yet. Share an insight, caveat, or question.
Tharun HK (2026) studied this question.
Synapse has enriched 8 closely related papers on similar clinical questions. Consider them for comparative context: