info prev up next book cdrom email home

Square Number

\begin{figure}\begin{center}\BoxedEPSF{SquareNumber.epsf scaled 600}\end{center}\end{figure}

A Figurate Number of the form $m=n^2$, where $n$ is an Integer. A square number is also called a Perfect Square. The first few square numbers are 1, 4, 9, 16, 25, 36, 49, ... (Sloane's A000290). The Generating Function giving the square numbers is

\begin{displaymath}
{x(x+1)\over(1-x)^3}=x+4x^2+9x^3+16x^4+\ldots.
\end{displaymath} (1)


The $k$th nonsquare number $a_k$ is given by

\begin{displaymath}
a_n=n+\left\lfloor{{\textstyle{1\over 2}}+\sqrt{n}}\right\rfloor ,
\end{displaymath} (2)

where $\left\lfloor{x}\right\rfloor $ is the Floor Function, and the first few are 2, 3, 5, 6, 7, 8, 10, 11, ... (Sloane's A000037).


The only numbers which are simultaneously square and Pyramidal (the Cannonball Problem) are $P_1=1$ and $P_{24}=4900$, corresponding to $S_1=1$ and $S_{70}=4900$ (Dickson 1952, p. 25; Ball and Coxeter 1987, p. 59; Ogilvy 1988), as conjectured by Lucas (1875, 1876) and proved by Watson (1918). The Cannonball Problem is equivalent to solving the Diophantine Equation

\begin{displaymath}
y^2={\textstyle{1\over 6}} x(x+1)(2x+1)
\end{displaymath} (3)

(Guy 1994, p. 147).


The only numbers which are square and Tetrahedral are $Te_1=1$, $Te_2=4$, and $Te_{48}=19600$ (giving $S_1=1$, $S_2=4$, and $S_{140}=19600$), as proved by Meyl (1878; cited in Dickson 1952, p. 25; Guy 1994, p. 147). In general, proving that only certain numbers are simultaneously figurate in two different ways is far from elementary.


To find the possible last digits for a square number, write $n=10a+b$ for the number written in decimal Notation as $ab_{10}$ ($a$, $b=0$, 1, ..., 9). Then

\begin{displaymath}
n^2=100a^2+20ab+b^2,
\end{displaymath} (4)

so the last digit of $n^2$ is the same as the last digit of $b^2$. The following table gives the last digit of $b^2$ for $b=0$, 1, ..., 9. As can be seen, the last digit can be only 0, 1, 4, 5, 6, or 9.

0 1 2 3 4 5 6 7 8 9
0 1 4 9 _6 _5 _6 _9 _4 _1


We can similarly examine the allowable last two digits by writing $abc_{10}$ as

\begin{displaymath}
n=100a+10b+c,
\end{displaymath} (5)

so
$\displaystyle n^2$ $\textstyle =$ $\displaystyle (100a+10b+c)^2$  
  $\textstyle =$ $\displaystyle 10^4 a^2+2(1000ab+100ac+10bc)+100b^2+c^2$  
  $\textstyle =$ $\displaystyle (10^4a^2+2000ab+100ac+100b^2)+20bc+c^2,$  
      (6)

so the last two digits are given by $20bc+c^2=c(20b+c)$. But since the last digit must be 0, 1, 4, 5, 6, or 9, the following table exhausts all possible last two digits.

c $b$
  0 1 2 3 4 5 6 7 8 9
1 01 21 41 61 81 _01 _21 _41 _61 _81
4 16 96 _76 _56 _36 _16 _96 _76 _56 _36
5 25 _25 _25 _25 _25 _25 _25 _25 _25 _25
6 36 _56 _76 _96 _16 _36 _56 _76 _96 _16
9 81 _61 _41 _21 _01 _81 _61 _41 _21 _01

The only possibilities are 00, 01, 04, 09, 16, 21, 24, 25, 29, 36, 41, 44, 49, 56, 61, 64, 69, 76, 81, 84, 89, and 96, which can be summarized succinctly as 00, $e1$, $e4$, 25, $o6$, and $e9$, where $e$ stands for an Even Number and $o$ for an Odd Number. Additionally, unless the sum of the digits of a number is 1, 4, 7, or 9, it cannot be a square number.


The following table gives the possible residues mod $n$ for square numbers for $n=1$ to 20. The quantity $s(n)$ gives the number of distinct residues for a given $n$.

$n$ $s(n)$ $x^2{\rm\ (mod\ }n)$
2 2 0, 1
3 2 0, 1
4 2 0, 1
5 3 0, 1, 4
6 4 0, 1, 3, 4
7 4 0, 1, 2, 4
8 3 0, 1, 4
9 4 0, 1, 4, 7
10 6 0, 1, 4, 5, 6, 9
11 6 0, 1, 3, 4, 5, 9
12 4 0, 1, 4, 9
13 7 0, 1, 3, 4, 9, 10, 12
14 8 0, 1, 2, 4, 7, 8, 9, 11
15 6 0, 1, 4, 6, 9, 10
16 4 0, 1, 4, 9
17 9 0, 1, 2, 4, 8, 9, 13, 15, 16
18 8 0, 1, 4, 7, 9, 10, 13, 16
19 10 0, 1, 4, 5, 6, 7, 9, 11, 16, 17
20 6 0, 1, 4, 5, 9, 16

In general, the Odd squares are congruent to 1 (mod 8) (Conway and Guy 1996). Stangl (1996) gives an explicit formula by which the number of squares $s(n)$ in $\Bbb{Z}_n$ (i.e., mod $n$) can be calculated. Let $p$ be an Odd Prime. Then $s(n)$ is the Multiplicative Function given by

$\displaystyle s(2)$ $\textstyle =$ $\displaystyle 2$ (7)
$\displaystyle s(p)$ $\textstyle =$ $\displaystyle {\textstyle{1\over 2}}(p+1)\qquad (p\not=2)$ (8)
$\displaystyle s(p^2)$ $\textstyle =$ $\displaystyle {\textstyle{1\over 2}}(p^2-p+2)\qquad (p\not=2)$ (9)
$\displaystyle s(2^n)$ $\textstyle =$ $\displaystyle \left\{\begin{array}{ll} {\textstyle{1\over 3}}(2^{n-1}+4) & \mbo...
...n}\\  {\textstyle{1\over 3}}(2^{n-1}+5) & \mbox{for $n$\ odd}\end{array}\right.$ (10)
$\displaystyle s(p^n)$ $\textstyle =$ $\displaystyle \left\{\begin{array}{ll} {p^{n+1}+p+2\over 2(p+1)} & \mbox{for $n...
...n}\\  {p^{n+1}+2p+1\over 2(p+1)} & \mbox{for $n\geq 3$\ odd.}\end{array}\right.$ (11)

$s(n)$ is related to the number $q(n)$ of Quadratic Residues in $\Bbb{Z}_n$ by
\begin{displaymath}
q(p^n)=s(p^n)-s(p^{n-2})
\end{displaymath} (12)

for $n\geq 3$ (Stangl 1996).


For a perfect square $n$, $(n/p)=0$ or 1 for all Odd Primes $p<n$ where $(n/p)$ is the Legendre Symbol. A number $n$ which is not a perfect square but which satisfies this relationship is called a Pseudosquare.


The minimum number of squares needed to represent the numbers 1, 2, 3, ... are 1, 2, 3, 1, 2, 3, 4, 2, 1, 2, ... (Sloane's A002828), and the number of distinct ways to represent the numbers 1, 2, 3, ... in terms of squares are 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, ... (Sloane's A001156). A brute-force algorithm for enumerating the square permutations of $n$ is repeated application of the Greedy Algorithm. However, this approach rapidly becomes impractical since the number of representations grows extremely rapidly with $n$, as shown in the following table.

$n$ Square Partitions
10 4
50 104
100 1116
150 6521
200 27482


Every Positive integer is expressible as a Sum of (at most) $g(2)=4$ square numbers (Waring's Problem). (Actually, the basis set is $\{0, 1, 4, 9, 16, 25, 36, 64, 81, 100, \ldots\}$, so 49 need never be used.) Furthermore, an infinite number of $n$ require four squares to represent them, so the related quantity $G(2)$ (the least Integer $n$ such that every Positive Integer beyond a certain point requires $G(2)$ squares) is given by $G(2)=4$.


Numbers expressible as the sum of two squares are those whose Prime Factors are of the form $4k-1$ taken to an Even Power. Numbers expressible as the sum of three squares are those not of the form $4^k(8l+7)$ for $k, l\geq 0$. The following table gives the first few numbers which require $N=1$, 2, 3, and 4 squares to represent them as a sum.

$N$ Sloane Numbers
1 Sloane's A000290 1, 4, 9, 16, 25, 36, 49, 64, 81, ...
2 Sloane's A000415 2, 5, 8, 10, 13, 17, 18, 20, 26, 29, ...
3 Sloane's A000419 3, 6, 11, 12, 14, 19, 21, 22, 24, 27, ...
4 Sloane's A004215 7, 15, 23, 28, 31, 39, 47, 55, 60, 63, ...


The Fermat 4n+1 Theorem guarantees that every Prime of the form $4n+1$ is a sum of two Square Numbers in only one way.


There are only 31 numbers which cannot be expressed as the sum of distinct squares: 2, 3, 6, 7, 8, 11, 12, 15, 18, 19, 22, 23, 24, 27, 28, 31, 32, 33, 43, 44, 47, 48, 60, 67, 72, 76, 92, 96, 108, 112, 128 (Sloane's A001422; Guy 1994). All numbers $>188$ can be expressed as the sum of at most five distinct squares, and only

\begin{displaymath}
124=1+4+9+25+36+49
\end{displaymath} (13)

and
\begin{displaymath}
188=1+4+9+25+49+100
\end{displaymath} (14)

require six distinct squares (Bohman et al. 1979; Guy 1994, p. 136). In fact, 188 can also be represented using seven distinct squares:
\begin{displaymath}
188=1+4+9+25+36+49+64.
\end{displaymath} (15)

The following table gives the numbers which can be represented in $W$ different ways as a sum of $S$ squares. For example,

\begin{displaymath}
50=1^2+7^2=5^2+5^2
\end{displaymath}

can be represented in two ways ($W=2$) by two squares ($S=2$).

$S$ $W$ Sloane Numbers
1 1 Sloane's A000290 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, ...
2 1 Sloane's A025284 2, 5, 8, 10, 13, 17, 18, 20, 25, 26, 29, 32, ...
2 2 Sloane's A025285 50, 65, 85, 125, 130, 145, 170, 185, 200, ...
3 1 Sloane's A025321 3, 6, 9, 11, 12, 14, 17, 18, 19, 21, 22, 24, ...
3 2 Sloane's A025322 27, 33, 38, 41, 51, 57, 59, 62, 69, 74, 75, ...
3 3 Sloane's A025323 54, 66, 81, 86, 89, 99, 101, 110, 114, 126, ...
3 4 Sloane's A025324 129, 134, 146, 153, 161, 171, 189, 198, ...
4 1 Sloane's A025357 4, 7, 10, 12, 13, 15, 16, 18, 19, 20, 21, 22, ...
4 2 Sloane's A025358 31, 34, 36, 37, 39, 43, 45, 47, 49, 50, 54, ...
4 3 Sloane's A025359 28, 42, 55, 60, 66, 67, 73, 75, 78, 85, 95, 99, ...
4 4 Sloane's A025360 52, 58, 63, 70, 76, 84, 87, 91, 93, 97, 98, 103, ...


The number of Integers $<x$ which are squares or sums of two squares is

\begin{displaymath}
N(x)\sim kx(\ln x)^{-1/2},
\end{displaymath} (16)

where
\begin{displaymath}
k=\sqrt{{1\over 2}\prod_{\scriptstyle r=4n+3\atop\scriptstyle r{\rm\ prime}} (1-r^{-2})^{-1}}
\end{displaymath} (17)

(Landau 1908; Le Lionnais 1983, p. 31). The product of four distinct Nonzero Integers in Arithmetic Progression is square only for ($-3$, $-1$, 1, 3), giving $(-3)(-1)(1)(3)=9$ (Le Lionnais 1983, p. 53). It is possible to have three squares in Arithmetic Progression, but not four (Dickson 1952, pp. 435-440). If these numbers are $r^2$, $s^2$, and $t^2$, there are Positive Integers $p$ and $q$ such that
$\displaystyle r$ $\textstyle =$ $\displaystyle \vert p^2-2pq-q^2\vert$ (18)
$\displaystyle s$ $\textstyle =$ $\displaystyle p^2+q^2$ (19)
$\displaystyle t$ $\textstyle =$ $\displaystyle p^2+2pq-q^2,$ (20)

where $(p,q)=1$ and one of $r$, $s$, or $t$ is Even (Dickson 1952, pp. 437-438). Every three-term progression of squares can be associated with a Pythagorean Triple $(X, Y, Z$) by
$\displaystyle X$ $\textstyle =$ $\displaystyle {\textstyle{1\over 2}}(r+t)$ (21)
$\displaystyle Y$ $\textstyle =$ $\displaystyle {\textstyle{1\over 2}}(t-r)$ (22)
$\displaystyle Z$ $\textstyle =$ $\displaystyle s$ (23)

(Robertson 1996).


Catalan's Conjecture states that 8 and 9 ($2^3$ and $3^2$) are the only consecutive Powers (excluding 0 and 1), i.e., the only solution to Catalan's Diophantine Problem. This Conjecture has not yet been proved or refuted, although R. Tijdeman has proved that there can be only a finite number of exceptions should the Conjecture not hold. It is also known that 8 and 9 are the only consecutive Cubic and square numbers (in either order).


A square number can be the concatenation of two squares, as in the case $16=4^2$ and $9=3^2$ giving $169=13^2$.


It is conjectured that, other than $10^{2n}$, $4\times 10^{2n}$ and $9\times 10^{2n}$, there are only a Finite number of squares $n^2$ having exactly two distinct Nonzero Digits (Guy 1994, p. 262). The first few such $n$ are 4, 5, 6, 7, 8, 9, 11, 12, 15, 21, ... (Sloane's A016070), corresponding to $n^2$ of 16, 25, 36, 49, 64, 81, 121, ... (Sloane's A018884).


The following table gives the first few numbers which, when squared, give numbers composed of only certain digits. The only known square number composed only of the digits 7, 8, and 9 is 9. Vardi (1991) considers numbers composed only of the square digits: 1, 4, and 9.


Digits Sloane $n$, $n^2$
1, 2, 3 Sloane's A030175 1, 11, 111, 36361, 363639, ...Sloane's A
  Sloane's A030174 1, 121, 12321, 1322122321, ...Sloane's A
1, 4, 6 Sloane's A027677 1, 2, 4, 8, 12, 21, 38, 108, ...Sloane's A
  Sloane's A027676 1, 4, 16, 64, 144, 441, 1444, ...Sloane's A
1, 4, 9 Sloane's A027675 1, 2, 3, 7, 12, 21, 38, 107, ...Sloane's A
  Sloane's A006716 1, 4, 9, 49, 144, 441, 1444, 11449, ...Sloane's A
2, 4, 8 Sloane's A027679 2, 22, 168, 478, 2878, 210912978, ...Sloane's A
  Sloane's A027678 4, 484, 28224, 228484, 8282884, ...Sloane's A
4, 5, 6 Sloane's A030177 2, 8, 216, 238, 258, 738, 6742, ...Sloane's A
  Sloane's A030176 4, 64, 46656, 56644, 66564, ...


Brown Numbers are pairs $(m,n)$ of Integers satisfying the condition of Brocard's Problem, i.e., such that

\begin{displaymath}
n!+1=m^2,
\end{displaymath} (24)

where $n!$ is a Factorial. Only three such numbers are known: (5,4), (11,5), (71,7). Erdös conjectured that these are the only three such pairs.


Either $5x^2+4=y^2$ or $5x^2-4=y^2$ has a solution in Positive Integers Iff, for some $n$, $(x,y)=(F_n,L_n)$, where $F_n$ is a Fibonacci Number and $L_n$ is a Lucas Number (Honsberger 1985, pp. 114-118).


The smallest and largest square numbers containing the digits 1 to 9 are

\begin{displaymath}
11,826^2=139,854,276,
\end{displaymath} (25)


\begin{displaymath}
30,384^2=923,187,456.
\end{displaymath} (26)

The smallest and largest square numbers containing the digits 0 to 9 are
\begin{displaymath}
32,043^2=1,026,753,849,
\end{displaymath} (27)


\begin{displaymath}
99,066^2=9,814,072,356
\end{displaymath} (28)

(Madachy 1979, p. 159). The smallest and largest square numbers containing the digits 1 to 9 twice each are
\begin{displaymath}
335,180,136^2=112,345,723,568,978,496
\end{displaymath} (29)


\begin{displaymath}
999,390,432^2=998,781,235,573,146,624,
\end{displaymath} (30)

and the smallest and largest containing 1 to 9 three times are


\begin{displaymath}
10,546,200,195,312^2=111,222,338,559,598,866,946,777,344
\end{displaymath} (31)


\begin{displaymath}
31,621,017,808,182^2=999,888,767,225,363,175,346,145,124\eqnnum
\end{displaymath}

(Madachy 1979, p. 159).


Madachy (1979, p. 165) also considers number which are equal to the sum of the squares of their two ``halves'' such as

$\displaystyle 1233$ $\textstyle =$ $\displaystyle 12^2+33^2$ (32)
$\displaystyle 8833$ $\textstyle =$ $\displaystyle 88^2+33^2$ (33)
$\displaystyle 10100$ $\textstyle =$ $\displaystyle 10^2+100^2$ (34)
$\displaystyle 5882353$ $\textstyle =$ $\displaystyle 588^2+2353^2,$ (35)

in addition to a number of others.

See also Antisquare Number, Biquadratic Number, Brocard's Problem, Brown Numbers, Cannonball Problem, Catalan's Conjecture, Centered Square Number, Clark's Triangle, Cubic Number, Diophantine Equation, Fermat 4n+1 Theorem, Greedy Algorithm, Gross, Lagrange's Four-Square Theorem, Landau-Ramanujan Constant, Pseudosquare, Pyramidal Number, r(n), Squarefree, Square Triangular Number, Waring's Problem


References

Ball, W. W. R. and Coxeter, H. S. M. Mathematical Recreations and Essays, 13th ed. New York: Dover, p. 59, 1987.

Bohman, J.; Fröberg, C.-E.; and Riesel, H. ``Partitions in Squares.'' BIT 19, 297-301, 1979.

Conway, J. H. and Guy, R. K. The Book of Numbers. New York: Springer-Verlag, pp. 30-32, 1996.

Dickson, L. E. History of the Theory of Numbers, Vol. 2: Diophantine Analysis. New York: Chelsea, 1952.

Grosswald, E. Representations of Integers as Sums of Squares. New York: Springer-Verlag, 1985.

Guy, R. K. ``Sums of Squares'' and ``Squares with Just Two Different Decimal Digits.'' §C20 and F24 in Unsolved Problems in Number Theory, 2nd ed. New York: Springer-Verlag, pp. 136-138 and 262, 1994.

Honsberger, R. ``A Second Look at the Fibonacci and Lucas Numbers.'' Ch. 8 in Mathematical Gems III. Washington, DC: Math. Assoc. Amer., 1985.

Le Lionnais, F. Les nombres remarquables. Paris: Hermann, 1983.

Lucas, É. Question 1180. Nouv. Ann. Math. Ser. 2 14, 336, 1875.

Lucas, É. Solution de Question 1180. Nouv. Ann. Math. Ser. 2 15, 429-432, 1876.

Madachy, J. S. Madachy's Mathematical Recreations. New York: Dover, pp. 159 and 165, 1979.

Meyl, A.-J.-J. Solution de Question 1194. Nouv. Ann. Math. 17, 464-467, 1878.

Ogilvy, C. S. and Anderson, J. T. Excursions in Number Theory. New York: Dover, pp. 77 and 152, 1988.

Pappas, T. ``Triangular, Square & Pentagonal Numbers.'' The Joy of Mathematics. San Carlos, CA: Wide World Publ./Tetra, p. 214, 1989.

Pietenpol, J. L. ``Square Triangular Numbers.'' Amer. Math. Monthly 69, 168-169, 1962.

Robertson, J. P. ``Magic Squares of Squares.'' Math. Mag. 69, 289-293, 1996.

Stangl, W. D. ``Counting Squares in $\Bbb{Z}_n$.'' Math. Mag. 69, 285-289, 1996.

Taussky-Todd, O. ``Sums of Squares.'' Amer. Math. Monthly 77, 805-830, 1970.

Vardi, I. Computational Recreations in Mathematica. Reading, MA: Addison-Wesley, pp. 20 and 234-237, 1991.

Watson, G. N. ``The Problem of the Square Pyramid.'' Messenger. Math. 48, 1-22, 1918.



info prev up next book cdrom email home

© 1996-9 Eric W. Weisstein
1999-05-26