Check If an Integer Is Symmetric
Check if an integer is a palindrome (symmetric number). Instantly verify if a number reads the same forwards and backwards with history tracking.
About
A symmetric integer, formally called a palindromic number, reads identically from left to right and right to left. The property is defined over the decimal digit sequence of a non-negative integer n. For a number with digits d1d2…dk, symmetry holds when di = dk−i+1 for all i. Negative integers are never palindromic by convention because the minus sign has no mirrored counterpart. Single-digit numbers (0 - 9) are trivially symmetric. Misidentifying palindromic numbers matters in competitive programming, cryptographic seed validation, and certain checksum algorithms where digit reversal invariance is a required property.
This tool validates symmetry by reversing the digit string and performing an exact comparison. It handles arbitrary-length integers limited only by JavaScript's string processing. Note: leading zeros are not valid integer representations, so inputs like 0120 are treated as 120 after normalization. The check runs in O(k) time where k is the digit count.
Formulas
An integer n with decimal digit representation d1d2…dk is symmetric (palindromic) if and only if:
Equivalently, the reversed digit string rev(n) must satisfy:
Where di is the i-th digit from the left, k is the total number of digits, and rev denotes the string reversal function. For negative integers, the minus sign is not a digit, so n < 0 &implies; FALSE. The algorithm complexity is O(k) time and O(k) space.
Reference Data
| Integer | Digits | Reversed | Symmetric? | Notes |
|---|---|---|---|---|
| 0 | 1 | 0 | Yes | Trivial single digit |
| 7 | 1 | 7 | Yes | All single digits are symmetric |
| 11 | 2 | 11 | Yes | Smallest 2-digit palindrome |
| 12 | 2 | 21 | No | - |
| 121 | 3 | 121 | Yes | Classic example |
| 123 | 3 | 321 | No | - |
| 1001 | 4 | 1001 | Yes | Even-length palindrome |
| 1234 | 4 | 4321 | No | - |
| 12321 | 5 | 12321 | Yes | Odd-length, center pivot at 3 |
| 1000001 | 7 | 1000001 | Yes | Sparse palindrome with inner zeros |
| 123454321 | 9 | 123454321 | Yes | Ascending-descending pattern |
| 1234567890 | 10 | 0987654321 | No | Reversed form has leading zero |
| −121 | 3 + sign | 121− | No | Negative integers are never symmetric |
| 9 | 1 | 9 | Yes | Largest single-digit palindrome |
| 99 | 2 | 99 | Yes | Repdigit - always palindromic |
| 10 | 2 | 01 | No | Trailing zero breaks symmetry |
| 1111111 | 7 | 1111111 | Yes | Repunit - always palindromic |
| 12344321 | 8 | 12344321 | Yes | Even-length mirror |
| 100 | 3 | 001 | No | Powers of 10 (except 1) are never symmetric |
| 98789 | 5 | 98789 | Yes | - |