What is the 3,141,592,653th positive even length palindromic integer in base 10?
A palindrome is a number which reads the same when written forward and backwards. The first 3 even length palindromes are 11, 22, and 33.
Source: https://codeforces.com/problemset/problem/688/B
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
We can notice a pattern if we look at the first few palindromes which gives intuition for the answer immediately: (quotes ' added for emphasis, they mean nothing) 1 ′ 1 , 2 ′ 2 , 3 ′ 3 , 4 ′ 4 , 5 ′ 5 , 6 ′ 6 , 7 ′ 7 , 8 ′ 8 , 9 ′ 9 , 1 0 ′ 0 1 , 1 1 ′ 1 1 , 1 2 ′ 2 1 , 1 3 ′ 3 1 , 1 4 ′ 4 1 , . . .
Hypothesis: the k th even length palindrome is the number k written forwards concatenated with it written backwards. Call this map (which takes an integer and returns the first even length palindrome starting with that integer) ϕ , it is injective since it sends no two elements to the same place.
To prove this, note that any even length palindrome is a number written forwards concatenated with itself written backwards, by definition of a palindrome, so ϕ is surjective. As it's also injective, ϕ is a bijection. Notice that for any two natural numbers a and b, ϕ ( a ) > ϕ ( b ) if and only if a is larger than b. Thus the map ϕ also preserves order, and is a isomorphism, and so the k th palindrome is given by ϕ ( k ) .
In particular, ϕ ( 3 , 1 4 1 , 5 9 2 , 6 5 3 ) = 3 1 4 1 5 9 2 6 5 3 ′ 3 5 6 2 9 5 1 4 1 3 .