Palindrome Number Calculator
Reverse the digits of an integer to see whether it reads the same backwards, with the reversed value shown.
What it does
A palindromic number keeps the same value when its digits are written in reverse order. Examples include 7, 121 and 12321. The word comes from the same root as the literary palindrome, a phrase that reads alike in both directions.
Checking a number is a matter of comparing its digit string with the same string turned around. No arithmetic is required, just an ordering test. That makes the idea easy to explain and a common first exercise when learning to work with strings in a programming language.
Palindromes have a few neat properties. Every power of ten is one, because it is a one followed by zeros and reverses to zeros followed by a one, which is the same number once leading zeros are dropped. Every single digit number qualifies as well. Among two digit numbers only the repeated ones such as 22 and 99 work.
This page reverses the decimal digits, counts them and places the reversed string beside the original. If the two match it reports a palindrome; otherwise it reports the mismatch. Leading zeros are handled by treating the input as a number before it is written out, so 010 is read as 10.
The limit is one trillion to keep the displayed values short and the input exact. The tool works in base ten only, since changing base would change which numbers are palindromes.
How to use
- Enter a whole number n from 0 upward.
- Read the verdict in the main result box.
- Compare the reversed digits shown beside it with your input.
- Check the digit count when you want to confirm the string length.
- Use the default 12321 to reproduce the worked example.
- Try 1234 to see a non palindrome and its reversed value.
Formula
- n
- The non negative integer being tested.
- s
- The decimal digit string of n, with no leading zeros.
- reverse(s)
- The same characters written in the opposite order.
The comparison is on the string, not on a numeric difference. For 12321 the reversed string is also 12321, so the test passes. For 1234 the reverse is 4321, which differs, so the test fails. Any one digit string equals its own reverse, which is why 0 through 9 are all palindromes.
Worked example
Example: 12321
The tool starts with n = 12321, the default input.
- Write the number as the digit string 1, 2, 3, 2, 1.
- Count the characters: there are 5 digits.
- Reverse the order to get 1, 2, 3, 2, 1 again.
- Join the reversed characters into the string 12321.
- Compare the two strings and find they match exactly.
- The tool reports Palindrome with reversed value 12321 and 5 digits.
- Checking 1234 by the same steps gives 4321, which does not match.
Reference table
| n | Reversed | Digits | Verdict |
|---|---|---|---|
| 0 | 0 | 1 | Palindrome |
| 7 | 7 | 1 | Palindrome |
| 121 | 121 | 3 | Palindrome |
| 1234 | 4321 | 4 | Not a palindrome |
| 12321 | 12321 | 5 | Palindrome |
| 123456 | 654321 | 6 | Not a palindrome |
Limits
- The check uses base ten digits only.
- Leading zeros are not preserved because the input is read as a number.
- Inputs above one trillion are rejected.
- The tool reports a simple equality test, not the reverse and add process used for Lychrel numbers.
Common mistakes
- Keeping leading zeros in the comparison, which can create a false match.
- Comparing numeric difference instead of the digit strings.
- Assuming an even number of digits cannot form a palindrome.
- Reversing only part of the number when it ends in zero.
- Confusing this test with a palindromic prime check.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is the reverse of 1234?
The reverse is 4321, which differs from 1234, so 1234 is not a palindrome.
Is 12321 a palindrome?
Yes. Reversing the digits gives 12321 again, the same five digit string.
Is a single digit such as 7 a palindrome?
Yes. A one character string always equals its own reverse.
Questions
What is a palindromic number?
A number whose decimal digits read the same in either direction.
Are all two digit palindromes multiples of eleven?
Yes. Numbers like 22, 33 and 99 are all eleven times one of the digits repeated.
How many palindromes have d digits?
There are ten with one digit, and otherwise nine times ten to the power of the floor of (d minus one) over two.
What is a palindromic prime?
A prime number that is also a palindrome, such as 131 or 10301.
What is the reverse and add process?
Adding a number to its reverse repeatedly, which sometimes leads to a palindrome and sometimes does not.
What numbers can this page check?
Whole numbers from 0 through 1,000,000,000,000. Larger entries return a readable error.