Palindrome Squares

My son asks me “What do the numbers 26, 264, 307 and 836 all have in common?” After enjoying my puzzled look for a moment, he tells me all their squares are palindromes, but they’re not palindromes themselves.

Most palindrome squares are squares of palindromes, like (11 * 11) == 121, (121 * 121) == 14641, and (22 * 22) == 484. When the digits in palindrome number are small, so there is no carrying when you square, then the square is also a palindrome. But there are a few squares that are palindromes even with all the carrying. Like (307 * 307) == 94249.

Now I can’t let an 11 year-old show me up like that. I may not know all the squares to 1000, but I do know how to program, so I whipped up the following to find more of these squares.

# squares.py
# Python code to find squares that are palindromes.
__author__ = 'nealabq@gmail.com'

def is_palindrome( int_in_question) :
    """
    True if int_in_question is an integer that is a
    palindrome when written in base 10.
    """
    # Change the number into a string and then a list.
    as_list_of_chars = list( str( int_in_question))
    # Copy the list and reverse it.
    reversed_list_of_chars = list( as_list_of_chars)
    reversed_list_of_chars.reverse( )
    # True if the list of chars is palindromic.
    return as_list_of_chars == reversed_list_of_chars

def print_palindrome_squares_up_to( limit) :
    """
    Prints all the positive integers up to but not
    including limit, where the integer's square is a
    palindrome but the integer itself is not. Also
    prints the square.
    """
    for i in range( limit) :
        if not is_palindrome( i) :
            if is_palindrome( i * i) :
                print( i, i * i)

Then I checked the first 100 million counting numbers. (This took a few minutes.)

>>> import squares
>>> squares.print_palindrome_squares_up_to( 100000000)
26 676
264 69696
307 94249
836 698896
2285 5221225
2636 6948496
22865 522808225
24846 617323716
30693 942060249
798644 637832238736
1042151 1086078706801
1109111 1230127210321
1270869 1615108015161
2012748 4051154511504
2294675 5265533355625
3069307 9420645460249
11129361 123862676268321
12028229 144678292876441
12866669 165551171155561
30001253 900075181570009
64030648 4099923883299904
>>>

And there you have it. Integer sequence A059744.

Be sure to check out Feng Yuan’s palindrome page, which says 2,554,237,742,555,355,264,685,484 (more than 2 quindecillion) squared is palindrome 6524130445402999318864545454688139992045440314256.

Perfect Day

Today is June 28, or 6/28, and 6 and 28 are the first two perfect numbers. It could only be more perfect if the year were 496 or 8128.

Happy Perfect Day!

Nth Root of N

During my son’s math lesson today we got on the subject of \sqrt[n]n, which I prefer to write as n^{1/n}. We made a table of a few obvious values and limits:

    \[ \begin{tabular}{|r|c|} \hline $n$ & $n^{1/n}$\\ \hline $0\leftarrow$ & $0\leftarrow$ \\ 1 & 1 \\ 2 & $\sqrt{2} \approx 1.414$ \\ 3 & $\sqrt[3]{3} \approx 1.442$ \\ 4 & $\sqrt{2} \approx 1.414$ \\ $\rightarrow \infty$ & $\rightarrow 1$ \\ \hline \end{tabular}\]

So the values rise from n=0 \cdots 2, peak somewhere in n=2 \cdots 4, and asymptotically drop to 1 after that. So the maximum is probably between 2 and 4, and I asked my son how we could find it. And he suggested we find where the curve is flat and the derivative is zero.

And that’s when I realized I’d forgotten know how to find \frac{d}{dx}(x^{1/x}). My son is only 11 and we’ve only touched on calculus, so he couldn’t help. I figure the first step is to express it as \frac{d}{dx}(e^\frac{ln(x)}{x}), but I don’t know where to go from there.

So we turn to the internet, and I read Wikipedia’s entry for the nth root algorithm, which doesn’t answer my question but is nice to read because it’s a little gem. And then we get to WolframAlpha, which tells us everything we want to know. See for yourself, the WolframAlpha page for \frac{d}{dx}(x^{1/x}), which says the derivative is x^\frac{1}{x}(\frac{1}{x^2} - \frac{log(x)}{x^2}), which is zero when \frac{1}{x^2}=\frac{log(x)}{x^2} or 1=log(x) or x=e.

So the maximum of \sqrt[n]n is \sqrt[e]e\approx 1.4447. Not very surprising, but nice to have it confirmed. (When I described this problem to my neighbor he said the max would be at e as soon as he heard it was between 2 and 4.)

But I still don’t know how to calculate that derivative, except by asking WolframAlpha. Which brings up the question, is the internet making me stupid by making things easy? Or is it making me smarter by taking care of drudgery? I’d like to say it makes me smarter, but I know that, once in a while, what appears to be drudgery at first turns out to be important, providing unexpected insight.


Powered by QuickLaTeX.com” and QuickLaTeX as a WordPress plugin.

Next Page →