17 minute read

Whether you love Number Theory, math competitions, or just have an affinity for numbers, there are many reasons why you would want to familiarize with perfect square numbers: numbers of the form \( x^2 \) where \( x \) is a positive integer. I memorized squares up to \( 20^2 = 400 \) in elementary school, and stopped thereafter. However, recently I thought maybe I would want to extend my knowledge of perfect squares up to \( 100^2 = 10000 \). Knowing and recognizing these squares can be useful for mental multiplication (in some cases), factoring expressions and even algorithms for mentally calculating square roots of arbitrary numbers!1 One might ask, and reasonably so, why should we memorize perfect squares when we could learn to derive them via fast mental calculations? First, having small squares memorized helps one recognize when encountering a square, whereas someone who uses calculations to derive these squares would have to apply a series of tests to confirm whether said number is a square and then obtain its square root. Furthermore, there is a strong structural pattern to the decimal representation of squares, which we will see later in this article, making it possible to memorize with techniques instead of blindly memorizing 400 numbers.2 This structural pattern is stronger than the prime numbers and 200 digits of pi, for example.

Of course, when it comes to memorizing numbers, one could sequentially memorize the entire chart (which has less than 400 individual digits). However, today’s challenge is to reveal that brute force memorization is not really necessary, and with a few tricks up your sleeves, you could effortlessly reconstruct the table of the first 100 squares. We will also discuss how to memorize the table after knowing the pattern. After all, there is a tradeoff in practically all mental calculation algorithms akin to the tradeoff between auxiliary space complexity and time complexity in computers. For humans, it is between the amount of calculation and amount of memorization. Memorized information is recited faster as the brain does not have to think any further than retrieving the memory, whereas more memory would be freed if you calculate each query directly.

A few years ago, when I attempted (but did not finish) memorizing the first 100 squares, I created a poster using LaTeX. Coming across it again, I gave it another try, noticed more patterns, and was finally able to complete the challenge.

Bag of Tricks

First, these tricks really help with the latter 91 of the first 100 squares: we have to ultimately assume the knowledge of the first nine squares: 1, 4, 9, 16, 25, 36, 49, 64, 81. This presents our first pattern: a last digit check. Since for a decimal number of the form \(ab\), \( (10a + b)^2 = 10(10a^2 + 2ab) + b^2 \), we see that the last digit of the square only depends on \( b \), and hence, we know from the first ten squares (including \( 0^2 = 0 \) or \( 10^2 = 100 \)) that the last digits form the pattern 1, 4, 9, 6, 5, 6, 9, 4, 1, 0.

Next, we will introduce a few tricks that rely on algebra in our “bag of tricks,” as classified on the cover image table. Note that these are introduced in order of calculation complexity, hence in the case of overlap, use the easier method, which occurs earlier. Also, although these methods are generally fast enough for real-time calculation, you do not need to use these methods on a number if its square has already been memorized correctly.

Ends in 5

There is a general rule for squaring numbers of the form \( 10n + 5 \) like 5, 15, 25, and so forth.

\[ (10n+5)^2 = 100n^2 + 100n + 25 = 100(n)(n+1) + 25 \]

An example application: 35 ends in 5, and 3*(3+1) = 12, so \( 35^2 = 1225 \).

Squares near 50 (41-59)

Where \( b \in [-9, 9] \cap \mathbb{Z} \), there is a quick rule for calculating squares of numbers of the form \( 50 + b \) (between 41 and 59).

\[ (50+b)^2 = 2500 + 100b + b^2 = 100(25+b) + b^2 \]

Let’s elucidate the case where \( b < 0 \) by replacing \( b \) with \( -b \).

\[ (50-b)^2 = 2500 - 100b + b^2 = 100(25-b) + b^2 \]

This is easier to apply in the following alternative form:

\[ (40+a)^2 = (50-(10-a))^2 = 2500 - 100(10-a) + (10-a)^2 = 100(15+a) + (10-a)^2 \]

Example applications:

  • 57 = 50 + 7, 25 + 7 = 32, and 7^2 = 49, so 57^2 = 3249.
  • 46 = 40 + 6, 15 + 6 = 21, and 10 - 6 = 4, 4^2 = 16, so 26^2 = 2116.
    Alternatively, 46 = 50 - 4, 25 - 4 = 21, and 4^2 = 16, yielding 2116 as well.

Squares near 100 (91-99)

A variation of the same rule applies for squares near 100 (91-109). Since squares above 100 are beyond the scope of today’s challenge, this rule essentially gives us nine free squares.

\[ (100+b)^2 = 10000 + 200b + b^2 = 100(100+2b) + b^2 \]

and

\[ (100-b)^2 = 10000 - 200b + b^2 = 100(100-2b) + b^2 \]

\[ (90+a)^2 = (100-(10-a))^2 = 100(80+2a) + (10-a)^2 \]

Example applications:

  • 107 = 100 + 7, 100 + 2*7 = 114, 7^2 = 49, so 107^2 = 11449.
  • 94 = 90 + 4, 80 + 2*4 = 88, and 10 - 4 = 6, 6^2 = 36, so 94^2 = 8836.
    Alternatively, 94 = 100 - 6, 100 - 2*6 = 88, 6^2 = 36, yielding 8836 as well.

Other Squares

This is not really a trick, it is just to explain the classification of “trivial” and “redundant” squares on the cover image poster. Redundant squares are the squares of numbers that are multiples of 10. \( (10a)^2 = 100a^2 \), so this just amounts to adding two zeroes after a known square.

The trivial squares are powers of 2 and 3 that I knew beforehand, simplifying some calculations. For example, if I am asked to calculate \( 64^2 \), I will remember that \( 64 \) is \( 2^6 \), and hence \( 64^2 = 2^{12} = 4096 \). The only exponential sequence that I memorized are the powers of two. These vary from people to people, but I added them as people generally know numbers such as \( 729 = 9^3 \).

The Rest of Them

Now that we’ve covered over 50% of the perfect squares less than 100, how do we go about the rest of them?

Last Two Digits

Well, the key is to notice the patterns that lie within the last two digits of those squares. For this, you will have to memorize only twelve ending digit pairs. These last digits are:

  1. (21, 44, 69, 96)
  2. (41, 84, 29, 76)
  3. (61, 89, 24, 56)

Notice that their final digits all follow the pattern 1, 4, 9, 6, which we’ve discussed earlier. Here’s one way you could remember these through smaller squares:

  • 11^2 = 121, 12^2 = 144, 13^2 = 169, 14^2 = 196.
  • 19^2 = 361, 18^2 = 324, 17^2 = 289, 16^2 = 256,
    Alternatively, 31^2 = 961, 32^2 = 1024, 33^2 = 1089, 34^2 = 1156.
  • 21^2 = 441, 22^2 = 484, 23^2 = 529, 24^2 = 576.

Here’s how they function in the squares between 10 and 40. Let i& denote the i pattern but in retrograde (backwards). The squares 11-19 follows 1 (5) 3&, meaning that the last two digits first goes through 1, hits 25 at 15^2 = 225, and then goes through 3 in reverse.3 Below are the same patterns for 21-29 and 31-39. Check the poster above to see that this pattern holds.

  • 11-19: 1 (5) 3&
  • 21-29: 2 (5) 2&
  • 31-39: 3 (5) 1& (The mirror image of 11-19).

The other trick is a generalization of the 50 rule: although the 50 rule can no longer easily predict the first two digits after the magnitude of \( b \) exceeds 10, it could still predict the last two digits. From this rule, we could derive that for any positive integer \( b \), \( b^2 \) ends in the same two digits as \( (50+b)^2 \), meaning that the ending digits pattern for 61-69 will be the same as 11-19, 71-79 with 21-29, and 81-89 with 31-39. To check that this rule is consistent, verify that the ending two digits of the squares 41-49 is indeed the same as 91-99.

First Two Digits

At this point, we could construct a table using all the information we already have from our bag of tricks and the last two digits pattern. For the sake of generality, let’s temporarily forget the “trivial squares.”

1 4 9 16 25 36 49 64 81 100
21 44 69 96 225 56 89 24 61 400
41 84 29 76 625 76 29 84 41 900
61 24 89 56 1225 96 69 44 21 1600
1681 1764 1849 1936 2025 2116 2209 2304 2401 2500
2601 2704 2809 2916 3025 3136 3249 3364 3481 3600
21 44 69 96 4225 56 89 24 61 4900
41 84 29 76 5625 76 29 84 41 6400
61 24 89 56 7225 96 69 44 21 8100
8281 8464 8649 8836 9025 9216 9409 9604 9801 10000

Upon inspection, there are 48 squares that we still have to fill in. There is a simple rule for this. On any given square, start with the first digits (hundreds and above) of the last cell (the cell containing the last square), and paste it into the current cell after determining whether it is necessary to increment the value by one or two (hundred) using the following rules.

  • For squares 11-39, if the current last two digits is less than the previous last two digits, increment the first digit(s) by 1, otherwise leave it as is.
  • For squares 61-89, if the current last two digits is less than the previous last two digits, increment the first digit(s) by 2, otherwise increment it by 1.

Here’s a quick walkthrough:

  • Starting at 30^2 = 900, the first digit is 9, and 31^2 ends in 61, and 00 < 61, so we keep 9: 31^2 = 961.
  • The first digit is still 9, 32^2 ends in 24, and 61 > 24, so we increment 9 to get 10: 32^2 = 1024.
  • The first digit is 10, 33^2 ends in 89, and 24 < 89, so we keep 10: 33^2 = 1089.
  • The first digit is still 10, 34^2 ends in 56, and 89 > 56, so we increment 10 to get 11: 34^2 = 1156.
  • Taking this one step further, the first digit is now 11, 35^2 ends in 25, and 56 > 25, so we increment 11 to get 12.
    This rule tells us that 35^2 = 1225, which is consistent with what we know from previous rules.

And another example in the 61-89 range

  • Starting at 75^2 = 5625, the first digits are 56, and 76^2 ends in 76, and 25 < 61, so we only increment 56 by 1 to get 57: 76^2 = 5776.
  • The first digit is 57, 77^2 ends in 29, and 76 > 29, so we increment 9 by 2 to get 59: 77^2 = 5929.
  • The first digit is 59, 78^2 ends in 84, and 29 < 84, so we only increment 59 by 1 to get 60: 78^2 = 6084.
  • The first digit is 60, 79^2 ends in 41, and 84 > 41, so we increment 60 by 2 to get 62: 79^2 = 6241.
  • Taking this one step further, the first digit is now 62, 80^2 ends in 00, and 62 > 00, so we increment 62 by 2 to get 64.
    This rule tells us that 80^2 = 6400, which is also consistent with what we knew previously.

This rule could be easily verified from analysis of the expression \( (10a+b)^2 \).

This is actually the challenging part, although the rule is easy to apply, since each square depends on the square to its left, assuming that we have memorized the basic table above, we may have to construct up to four squares to find the first digit(s) of our square if we wish not to involve more complicated rules. This is where a memory-computation tradeoff happens. At this point, the best way to progress, in my opinion, is to gradually commit these first digits into memory as well, completing the full table.4

Committing to Memory

I’m no memory expert, so take my advice with a grain of salt. This is how I memorized the squares. I would first reconstruct the table using the rules that we came up with above without any external references (no additional calculation). Then, I scrapped a quick terminal python script to continuously test me on random squares in a selected range. When I cannot remember the square of the asked number, I would have to figure it out. In the interest of time, instead of recomputing it, I would sometimes just check the table in front of me. If my memory recall is incorrect, the script will tell me the correct answer and ask me to type it again to reinforce the correct number in my memory. Slowly, the numbers will begin sticking in my mind, some before others, and I would not have to use the lookup table anymore. This is the process going from “being able to construct it” to “knowing it.”

Here’s an example of what that script could look like. Since we’re only dealing with squares less than 100, it does not need to be very efficient.

from random import choice
ranges = [
    (11, 14), (16, 19), (21, 24), (26, 29), (31, 34), (36, 39),
    (51, 54), (56, 59), (61, 64), (66, 69), (71, 74), (76, 79)
]

def main():
    squares = []
    for start, end in ranges:
        for n in range(start, end+1):
            squares.append(n)
    while True:
        n = choice(squares)
        inp = input(f"What is {n}^2? ")
        correct = False
        while not correct:
            try:
                sq = int(inp)
                if (sq == n*n):
                    print("Correct!")
                    correct = True
                    continue
            except ValueError:
                pass
            inp = input(f"Wrong! {n}^2 = {n*n}. Try again: ")

if __name__ == '__main__':
    main()

Try to personalize this code, make it cleaner, or even add a statistics functionality to see which squares you are getting right all the time and which ones you are getting wrong.

This method worked pretty well for me as there was no reward/punishment system and it was simply focused on repetitive exposure to these numbers until they stick to memory. I used a similar method when learning Zhuyin, Hiragana, and Katakana.

One More Trick

There is one more benefit to analyzing the patterns in the last two digits of perfect squares in decimal. Although squares of numbers greater than 100 are left to mental calculation, these final two digit rules and patterns extend beyond the first 100 squares, and we can use our knowledge to immediately eliminate arbitrarily large numbers that are not perfect squares.5

The exhaustive list of possible last two digits of perfect squares are the squares 0-9 and the three sequences listed above (22 total).

00, 01, 04, 09, 16, 25, 36, 49, 64, 81, 21, 44, 69, 96, 41, 48, 29, 76, 61, 24, 89, 56

Let’s try an example: is 8844675 a perfect square? Well, since the ending digits 75 is not on the list above, there is no way it can be a perfect square. On the contrary, the number 8844676 could be a perfect square because 76 is on the list. However, this does not definitively confirm that 8844676 is a perfect square. After some calculations though, we can verify that \( 8844676 = 2974^2 \) is indeed a perfect square.6

Colophon for the Poster

In this section, I will briefly discuss how I made the poster in LaTeX for those who are curious. I made this a few years ago, and I did so by googling what I wanted, gaining new information, some of which lead in the right direction and gets me a bit closer to what I needed. I ended up using xcolor for the colours, and a few other packages for symbols or just to make my life easier.

\documentclass[12pt]{article}
\usepackage[landscape,margin=0.5in]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{amssymb,array,nopageno}

\newcolumntype{L}{>{$}l<{$}} % "l" column parameter but with automatic math-mode.

\makeatletter
\newif\if@darkmode\@darkmodetrue % toggle darkmode here.
\if@darkmode
\pagecolor{black}
\color{White}
\newcommand{\red}[1]{\color{OrangeRed}#1}
\newcommand{\orange}[1]{\color{Orange}#1}
\newcommand{\yellow}[1]{\color{Yellow}#1}
\newcommand{\blue}[1]{\color{ProcessBlue}#1}
\newcommand{\green}[1]{\color{Green}#1}
\newcommand{\purple}[1]{\color{Orchid}#1}
\else
\newcommand{\red}[1]{\color{Red}#1}
\newcommand{\orange}[1]{\color{RedOrange}#1}
\newcommand{\yellow}[1]{\color{BurntOrange}#1}
\newcommand{\blue}[1]{\color{RoyalBlue}#1}
\newcommand{\green}[1]{\color{Green}#1}
\newcommand{\purple}[1]{\color{Plum}#1}
\fi
\makeatother

\begin{document}
\begin{figure}
\centering
\begin{tabular}{LLLLLLLLLL}
& \green{1^2 = 1} & \green{2^2 = 4} & \green{3^2 = 9} & \green{4^2 = 16} & \green{5^2 = 25} & \green{6^2 = 36} & \green{7^2 = 49} & \green{8^2 = 64} & \green{9^2 = 81} \\ \\
\red{10^2 = 100} & 11^2 = 121 & 12^2 = 144 & 13^2 = 169 & 14^2 = 196 & \orange{15^2 = 225} & \blue{16^2 = 256} & 17^2 = 289 & 18^2 = 324 & 19^2 = 361 \\ \\
\red{20^2 = 400} & 21^2 = 441 & 22^2 = 484 & 23^2 = 529 & 24^2 = 576 & \orange{25^2 = 625} & 26^2 = 676 & \blue{27^2 = 729} & 28^2 = 784 & 29^2 = 841 \\ \\
\red{30^2 = 900} & 31^2 = 961 & \blue{32^2 = 1024} & 33^2 = 1089 & 34^2 = 1156 & \orange{35^2 = 1225} & 36^2 = 1296 & 37^2 = 1369 & 38^2 = 1444 & 39^2 = 1521 \\ \\
\red{40^2 = 1600} & \yellow{41^2 = 1681} & \yellow{42^2 = 1764} & \yellow{43^2 = 1849} & \yellow{44^2 = 1936} & \orange{45^2 = 2025} & \yellow{46^2 = 2116} & \yellow{47^2 = 2209} & \yellow{48^2 = 2304} & \yellow{49^2 = 2401} \\ \\
\red{50^2 = 2500} & \yellow{51^2 = 2601} & \yellow{52^2 = 2704} & \yellow{53^2 = 2809} & \yellow{54^2 = 2916} & \orange{55^2 = 3025} & \yellow{56^2 = 3136} & \yellow{57^2 = 3249} & \yellow{58^2 = 3364} & \yellow{59^2 = 3481} \\ \\
\red{60^2 = 3600} & 61^2 = 3721 & 62^2 = 3844 & 63^2 = 3969 & \blue{64^2 = 4096} & \orange{65^2 = 4225} & 66^2 = 4356 & 67^2 = 4489 & 68^2 = 4624 & 69^2 = 4761 \\ \\
\red{70^2 = 4900} & 71^2 = 5041 & 72^2 = 5184 & 73^2 = 5329 & 74^2 = 5476 & \orange{75^2 = 5625} & 76^2 = 5776 & 77^2 = 5929 & 78^2 = 6084 & 79^2 = 6241 \\ \\
\red{80^2 = 6400} & 81^2 = 6561 & 82^2 = 6724 & 83^2 = 6889 & 84^2 = 7056 & \orange{85^2 = 7225} & 86^2 = 7396 & 87^2 = 7569 & 88^2 = 7744 & 89^2 = 7921 \\ \\
\red{90^2 = 8100} & \purple{91^2 = 8281} & \purple{92^2 = 8464} & \purple{93^2 = 8649} & \purple{94^2 = 8836} & \orange{95^2 = 9025} & \purple{96^2 = 9216} & \purple{97^2 = 9409} & \purple{98^2 = 9604} & \purple{99^2 = 9801}
\end{tabular}
\end{figure}
\red{$\blacksquare$ Redundant Squares} \quad \orange{$\blacksquare$ 5 Squares} \quad \yellow{$\blacksquare$ Squares Near 50} \quad \green{$\blacksquare$ Principle Squares} \quad \blue{$\blacksquare$ Trivial Squares} \quad \purple{$\blacksquare$ Squares Near 100}
\end{document}

Since I didn’t want to type math-mode delimiters inside each individual cell, I used the array package to set a new column type in line 6. I also challenged myself to make it look pretty, and I ended up creating a dark mode that one can toggle using \@darkmodetrue and \@darkmodefalse. The table part of the LaTeX script was automatically generated by a python script, though the colour parameters were added in manually. Feel free to take this code and make something pretty and/or useful out of it.

The pdf was rendered by Overleaf, and the arrows were added later in Preview.app. Though they could be added in LaTeX, I thought it wasn’t worth the hassle. You can download a PDF version of the light-mode and dark-mode posters here.

  1. https://worldmentalcalculation.com/mental-square-roots-algorithm/ 

  2. There are at most 4 digits per perfect square less than \( 100^2 \) and 100 of them. 

  3. In case there is still some confusion, let’s walk through the 11-19 case. The relevant squares are 121, 144, 169, 196, 225, 256, 289, 324, 361. If we keep only the last two digits, we will have the sequence 21, 44, 69, 96, 25, 56, 89, 24, 61. Notice that the first four (21, 44, 69, 96) is sequence 1 and the last four (56, 89, 24, 61) is sequence 3 in reverse, hence we denoted it 1 (5) 3& for convenience. 

  4. Of course, this is only my opinion. Some may argue that no perfect square ought to be memorized, and that practicing computing all of them as they are needed is most beneficial, making this method quite pointless. 

  5. \( (100+n)^2 = 10000 + 200n + n^2 = 100(100+2n) + n^2 \), hence, only \( n^2 \) affects the last two digits. 

  6. Number theorists study these patterns in a field referred to as “Elementary Number Theory,” wherein they generalize these concepts to more digits, higher powers, and other bases as well; however, that is beyond the scope of this article.