Convert Integer to Palindrome

Generate palindromes from integers - 4 methods (reverse-append, mirror, add-reverse, nearest). BigInt-accurate. Free, offline, client-side.

Turn integers into palindromes with four classic methods - Reverse-and-Append, Mirror, Add-Reverse (the famous "196 problem"), and direct Nearest construction. All arithmetic uses BigInt, so numbers don't lose precision past 2^53.

Enter integers to convert.

How to Use Convert Integer to Palindrome

  1. Type or paste integers - one per line, or separated by commas, semicolons, or whitespace. Negative numbers work (sign preserved). The 200 ms debounce keeps the UI responsive while you type.
  2. Pick a method - Reverse & Append produces a clean even-length palindrome (123 → 123321). Mirror Digits gives the classic odd-length form (123 → 12321). Add Reverse is the famous iterative "196 problem". Find Nearest snaps to the closest existing palindrome.
  3. Read the breakdown - every input is paired with its output, the digit growth, the iteration count (Add Reverse only), and any warnings. Lychrel candidates (numbers like 196 that never seem to converge) are explicitly flagged after 50 iterations.
  4. Check the stats line - total processed, errors, average digit growth, and Lychrel-candidate count summarize the batch at a glance.
  5. Pick output separator - newline (default, great for code), comma (CSV-friendly), or space (single-line). Switching is instant, no recompute needed.
  6. Copy or download - Copy uses the async Clipboard API with execCommand fallback. Download saves palindromes.txt. Ctrl+Enter (⌘+Enter on Mac) forces a recompute.
  7. Trust BigInt - JavaScript's regular Number type silently loses precision past 2^53 (~16 digits). This tool uses BigInt throughout, so even a 10-digit input reverse-appended to 20 digits stays accurate to the last digit.

Frequently Asked Questions

What’s the difference between Reverse-Append and Mirror?

Reverse-Append concatenates the digits with their full reverse: 123 → 123 + 321 = 123321 (even-length, 2N digits). Mirror drops the first character of the reverse before appending: 123 → 123 + 21 = 12321 (odd-length, 2N-1 digits). Pick Mirror when you want a centered single-middle-digit palindrome.

What is the Add Reverse method (the “196 problem”)?

Take any number, add its reverse, check if the result is a palindrome. If not, repeat. Most numbers converge quickly: 195 → 195+591=786 → 786+687=1473 → 1473+3741=5214 → 5214+4125=9339 (palindrome in 4 steps). But 196 has been iterated billions of times without ever reaching a palindrome – it’s the smallest suspected “Lychrel number” in base 10.

What’s a Lychrel candidate?

An integer that has never been proven to reach a palindrome via the Add Reverse process. 196, 295, 394, 493, 592, 689, 691, 788, 790, 879… are the first 10 in base 10. None have been proven to never converge (Lychrel-ness isn’t mathematically settled), but billions of iterations on 196 have produced no palindrome. We cap at 50 iterations and flag any unresolved input.

How does Find Nearest work?

Direct construction in O(1): take the first half of the digits, mirror them to form a candidate palindrome, then also build two neighbors by bumping the first half ±1. Compare distances to the input. Two boundary candidates (the all-9s number one digit shorter, and the 10…01 number same length) are also considered. The smallest |candidate – input| wins.

Can I convert very large numbers without losing precision?

Yes. All arithmetic uses BigInt, so a 10-digit input reverse-appended to 20 digits keeps every digit accurate. JavaScript’s regular Number would lose the last 4 digits silently past 2^53 ≈ 16 digits. Try 9999999999 in Reverse-Append mode to see 99999999999999999999 (20 nines, all correct).

Do negative numbers work?

Yes. The method runs on the absolute value, and the sign is restored. -12 Reverse-Append → -1221. -196 Add Reverse → flagged Lychrel candidate (the absolute-value math is what matters).

What does “digit growth” mean in the stats?

How many digits the output has minus how many the input had. Reverse-Append always doubles the digit count (growth = N). Mirror grows by N-1. Add Reverse can grow significantly across iterations. Nearest typically stays at the same digit count (growth = 0).

Is my data uploaded anywhere?

No. Everything runs in your browser – just BigInt arithmetic and string operations. Open DevTools → Network and watch zero requests fire after the page loads. Safe for proprietary number sequences or anything private.

Does it work offline?

Yes. Total bundle is under 20 KB. Once the page loads, disconnect and keep converting. Works on planes, trains, or air-gapped machines.

Where would I use this practically?

Beyond the recreational math, palindrome construction is useful for stress-testing string/number reversal code, generating test data for palindrome-check algorithms, and exploring number-theoretic patterns. Computer-science classes use the 196 problem to motivate discussions of unproven conjectures.