Skip to content
πŸ› οΈToolsShed

Number Palindrome Checker

Check if a number is a palindrome, find palindromes in a range, and discover interesting palindromic numbers.

βœ…
12321
is a palindrome
Reversed: 12321

About this tool

A number palindrome is a number that reads the same forwards and backwards, like 121 or 3443. The Number Palindrome Checker lets you instantly verify whether any number is palindromic, explore ranges of palindromes to see patterns, and discover fascinating mathematical properties of these symmetric numbers.

Using the tool is straightforward: enter a single number to check if it's a palindrome, or specify a range to find all palindromes within it. You can examine how palindromes are distributed across different number ranges, from small integers to larger values, and gain insight into their frequency and mathematical characteristics.

This tool is useful for students learning about number theory, mathematicians exploring numeric patterns, and anyone curious about the quirky properties of numbers. While the checker works with any positive integer, very large numbers may take slightly longer to process, but the fundamental principle remains the same: true palindromes mirror perfectly around their center digits.

Frequently Asked Questions

Code Implementation

def is_palindrome(n) -> bool:
    """Check if a number (int or string) is a palindrome."""
    s = str(n)
    return s == s[::-1]

def next_palindrome(n: int) -> int:
    """Find the next palindrome after n."""
    n += 1
    while not is_palindrome(n):
        n += 1
    return n

def find_palindromes_in_range(start: int, end: int) -> list[int]:
    """Find all palindrome numbers in range [start, end]."""
    return [i for i in range(start, end + 1) if is_palindrome(i)]

# Check specific numbers
for num in [12321, 12345, 99999, 100001, 1234321]:
    result = "βœ“ palindrome" if is_palindrome(num) else "βœ— not palindrome"
    print(f"{num}: {result}")

# Find palindromes in range
print("\nPalindromes 100-200:", find_palindromes_in_range(100, 200))
print("Next palindrome after 999:", next_palindrome(999))
print("Next palindrome after 12345:", next_palindrome(12345))

# Lychrel number check (reverse and add)
def reverse_and_add(n: int, steps: int = 50) -> tuple[bool, int]:
    for _ in range(steps):
        n += int(str(n)[::-1])
        if is_palindrome(n):
            return True, n
    return False, n

print("\n196 Lychrel test:", reverse_and_add(196, 100)[0])  # Famous non-palindrome

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.