applets.

Palindromes

← All apps

About Palindromes

A palindrome reads the same backwards as forwards. CHECK A PHRASE strips out everything but the letters and digits, then folds what's left in the middle: the first letter is paired with the last, the second with the second last, and so on. Every pair that matches gets a tick; the first one that doesn't is ringed in red. Accents are ignored, so é counts as e.

REVERSE AND ADD takes a number, adds it to itself written backwards, and keeps going until the answer is a palindrome. Most numbers get there in a step or two; 89 takes 24. The map shows every number from 1 to 9,999 and how many steps it needs. PALINDROMIC NUMBERS has three more: squares of 11…1, palindromic primes, and numbers that are palindromes in more than one base.

THE STORY

This app grew from the Python script Palindrome_Checker.py, which keeps the letters and digits of a phrase, lowers their case and compares the result with itself reversed. Its sample phrase is the opener here: "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama!", a longer cousin of Leigh Mercer's "A man, a plan, a canal: Panama", published in 1948.

Palindromes are old. The Sator square, five Latin words (SATOR AREPO TENET OPERA ROTAS) that read the same in four directions, was scratched on walls in Pompeii, so it is older than the eruption of AD 79. The word itself comes from the Greek for "running back again". James Joyce made up tattarrattat for a knock at the door in Ulysses (1922). "Able was I ere I saw Elba" is often put in Napoleon's mouth, but it's an English joke, not his.

Reverse and add is the subject of the 196 problem. 196 + 691 = 887, 887 + 788 = 1,675, and so on, and no palindrome has ever turned up. John Walker ran it on a computer from 1987 to 1990 and reached a million digits; Tim Irvin passed two million in 1995, and later searchers took it past a billion digits, still without a palindrome. Numbers like this are called Lychrel numbers (Wade VanLandingham's name), but nobody has proved that 196, or any number in base 10, is one. In base 2 it has been proved: 10110 (22) never reaches a palindrome. Some numbers do get there after a very long wait: 1,186,060,307,891,929,990 takes 261 steps.

HOW IT WORKS

Checking: each character is split from its accent, lower-cased and kept only if it's a letter or digit, as the script does. Pairs are compared from both ends inwards; an odd length leaves one letter in the middle, which always matches itself.

Reverse and add uses whole-number arithmetic of any length, column by column with carries, as you would on paper; the column sum shows the carries in red. Here a number that is already a palindrome still takes at least one step, as in the definition of a Lychrel number: 4,994 reads the same both ways, but adding it to itself starts a chain that has never found another. The map counts steps up to 500; every number below 10,000 that gets there within 500 steps does so in 24 steps or fewer. The 249 that don't (unproved: nobody knows if they ever will) are drawn in colour by the thread they join: two numbers are on the same thread when their sums run into the same sequence (295 + 592 = 887, which is on 196's).

Squares of 1, 11, 111 … are palindromes up to nine 1s (111,111,111² = 12,345,678,987,654,321); with ten, the middle column carries and spoils it. Every palindrome with an even number of digits divides by 11 (its digits' alternating sum is 0), so 11 is the only palindromic prime with an even number of digits.

FURTHER WATCHING AND READING

FAMOUS ONES

PALINDROME

FOLDED IN THE MIDDLE

FORWARDS
BACKWARDS
Top row: the first half, left to right. Under each letter: its partner from the other end. ✓ match · ✗ no match · ringed: the first one out