# Is there a hidden relation between the sum of squares and the factorial?

Is there a hidden relation between the sum of squares and the factorial?

Two cases will be considered: the sum of odd squares and that of the even squares. We will not consider the classical sum of odd and even squares given by:

Case 1: $$1^2 +3^2 +5^2+\cdots+(2n+1)^2 = N$$
Case 2: $$2^2 +4^2 +6^2+\cdots+(2n)^2 = M$$

Instead, we will consider the sum of odd squares given by adding numbers starting with an odd number and and on the perpendicular to the main diagonal ( that of the squares themselves ) in the multiplication table. Here are two examples to clarify what is meant.

Case 1: $$3 + 4 + 3 = 10 = 1^2 + 3^2$$
Case 2: $$5 + 8 + 9 + 8 + 5 = 35 = 1^2 + 3^2 + 5^2$$

It's clear that if a diagonal start with an odd number, the sum of these numbers will provide the sum of odd squares. The same can be said if the starting number is an even number. Here are two examples to show how this works.

Case 1: $$4 + 6 + 6 + 4 = 20 = 2^2 + 4^2$$
Case 2: $$8 + 14 + 18 + 20 + 20 + 18 + 14 + 8 = 120 = 2^2 + 4^2 + 6^2 +8^2$$

Factorial $$N$$ can be calculated using the same numbers given above. If the starting number of a diagonal is odd, then the result of the multiplication of the numbers will give the factorial of that $$(N!)^2$$. The same thing applies to even starting numbers.

Case 1: $$(5!)^2= 5\cdot8\cdot9\cdot8\cdot5= 120^2 = (5\cdot8\cdot3)\cdot(3\cdot8\cdot5)$$
Case 2: $$(6!)^2= 6\cdot10\cdot12\cdot12\cdot10\cdot6= 720^2 = (6\cdot10\cdot12)\cdot(12\cdot10\cdot6)$$

The sum of squares, odd or even, is given by simple addition of the numbers located on the diagonal to the main diagonal of the multiplication table but the factorial is the product of these same numbers. There is a simple way to calculate $$N!$$ instead of $$(N!)^2$$.

I found the fact that the same numbers are used to calculate the sum of squares and a factorial odd and I am wondering if there is a hidden relation between the two.

Edit March 23 2023

How to express factorials as a product of difference of squares formed with the (partial) sum of squares numbers. However, the link to the sum of squares is no longer visible.

Example of $$20!$$

$$20!=20\cdot38\cdot54\cdot68\cdot80\cdot90\cdot98\cdot104\cdot108\cdot110$$.
We pair them two at a time to get the following result:

$$20!=(29^2-9^2)(61^2-7^2)(85^2-5^2)(101^2-3^2)(109^2-1^2)$$

$$(109^2-1^2)$$ is simply $$109=(108+110)/2$$ and $$1=(110-108)/2$$.

The subtracted squares values are determined by the distance to the main diagonal (of squares). We only have odd numbers square for the differences because of the pairing which skips some multiplications (like $$38\cdot54$$ because both are paired with other numbers).
I am not sure if the square form of the factorials is faster but it could be advantageous with the use of pre-stored squares. With odd numbers and even numbers like $$14$$ which when divided by $$2$$ give an odd number, there is always one number that cannot be paired.

• I must admit that only skimmed the question. But I want to point out that there are closed form formulas for the sums of squares (including just the evens or the odds), and writing these out would probably help you discern their relationships with other sequences or formulas. Mar 17, 2023 at 18:38
• I know about the formulas but I never saw the sum of squares calculated the way it's done above. Mar 17, 2023 at 18:44
• Cool pattern! The reason $N!$ appears is not so hard, I think - by definition of multiplication tables, in a product like $(1\cdot7)(2\cdot6)(3\cdot5)\dotsm(7\cdot1)$, you see that each number from $1$ to $7$ appears twice in the product, so the product is $(7!)^2$. I can't immediately think of a way to prove the thing about sums of squares without some very unenlightening and unsatisfying formula-crunching though. Mar 17, 2023 at 21:58
• For some intuition on the sum of squares, look at the $5$ example. We have $5, 5+3, 5+3+1, 5+3, 5$. That's $5$ $5$s, $3$ $3$s, and $1$ $1$, so $5^2+3^2+1^2$. I'm having a touch of trouble turning that into a proof starting from the expression $\sum_{k=1}^n k(n+1-k)$, but I think that'd be the best way to go. Mar 17, 2023 at 22:09
• That's a nice observation! I guess you mean combined with the pattern eyeballfrog mentions, you can generate this antidiagonal using only additions, so you genuinely only need to do $n/2$ multiplications? There's much to be read about computing $n!$ - for really big $n$, you don't only have to worry about the number of multiplications, but also the size of the numbers you're multiplying, as this becomes a big cost. There are methods that are faster than both the naïve method and your one, that involve prime powers - interesting discussion eg here. Mar 18, 2023 at 10:49

We start with a small example $$2n+1=7$$. Then we prove the formulas in the additive and multiplicative case for general odd positive numbers $$2n+1$$. We will then compare the tables and the proofs to see if there are some commonalities.

Additive case: $$n=7$$: \begin{align*} \begin{array}{rrrrrrr|r} 7&+12&+15&+16&+15&+12&+7\\ \hline =7&+7&+7&+7&+7&+7&+7&=7\cdot 7\\ &+5&+5&+5&+5&+5&&+5\cdot 5\\ &&+3&+3&+3&&&+3\cdot 3\\ &&&+1&&&&+1\cdot1 \end{array} \end{align*} The table above shows how the summands in the first row can be split into equal parts of odd numbers so that the sum of these equal parts is a square number given in the rightmost column.

In general we obtain \begin{align*} \color{blue}{\sum_{j=-n}^n}\color{blue}{\sum_{k=0}^{n-|j|}(2n+1-2k)} &=\sum_{{-n\le j\le n}\atop{0\le k\le n-|j|}}(2n+1-2k)\tag{1.1}\\ &=\sum_{{0\le k\le n}\atop{0\le |j|\le n-k}}(2n+1-2k)\tag{1.2}\\ &=\sum_{k=0}^n\sum_{j=-n+k}^{n-k}(2n+1-2k)\tag{1.3}\\ &=\sum_{k=0}^n(2n+1-2k)^2\tag{1.4}\\ &\,\,\color{blue}{=\sum_{k=0}^n(2k+1)^2}\tag{1.5} \end{align*}

• In (1.1) we write the index region a bit more conveniently to better seethe transformations which follow.

• In (1.2) we change the order of summation starting with $$k$$.

• In (1.3) we use two summation symbols again.

• In (1.4) we see the summands do not depend on $$j$$.

• In (1.5) we change the order of summation $$k\to n-k$$.

Multiplicative case $$2n+1=7$$:

Now we take a look at the multplicative case and start again with a small table.

\begin{align*} \begin{array}{ccccccc} 7&\cdot 12&\cdot 15&\cdot 16&\cdot 15&\cdot 12&\cdot 7\\ \hline =(7)&\cdot(7+5)&\cdot(7+5+3)&\cdot(7+5+3+1)&\cdot(7+5+3)&\cdot(7+5)&\cdot(7)\\ =(7)&\cdot(6+6)&\cdot(5+5+5)&\cdot(4+4+4+4)&\cdot(5+5+5)&\cdot(6+6)&\cdot(7)\\ =(7)&\cdot(2\cdot 6)&\cdot(3\cdot 5)&\cdot(4\cdot4)&(3\cdot 5)&\cdot(2\cdot 6)&\cdot(7)\\ \end{array} \end{align*} The rearrangements in the table above are significantly different compared with the additive case. Here are the arrangements within each factor of the first row only.

In general we take again odd positive numbers $$2n+1$$ and consider \begin{align*} \color{blue}{\prod_{j=-n}^n\sum_{k=0}^{n-|j|}(2n+1-2k)} \end{align*} We observe in case $$2n+1=7$$ the greatest factor $$16=7+5+3+1$$ has four summands. It is convenient to split the calculation into $$n=2m$$ and $$n=2m+1$$ and perform the calculation for even and odd number of summands of the greatest factor separately. Here we consider the even case $$n=2m$$ only. The odd case can be calculated similarly.

We have \begin{align*} \color{blue}{\prod_{j=-2m}^{2m}\sum_{k=0}^{2m-|j|}(4m+1-2k)}\tag{2.1} \end{align*} Since the calculation of the inner sum of (2.1) is a bit different depending on the parity of $$j$$, we consider two cases.

Case $$|j|=2q$$: We obtain

\begin{align*} \color{blue}{\sum_{k=0}^{2m-2q}}&\color{blue}{(4m+1-2k)}\\ &=\sum_{k=0}^{m-q-1}((4m+1-2k)+(4m+1-2(2m-2q-k))\\ &\qquad\qquad+4m+1-2(m-q)\tag{2.2}\\ &=\sum_{k=0}^{m-q-1}(4m+4q+2)+(2m+2q+1)\\ &=2\sum_{k=0}^{m-q-1}(2m+2q+1)+(2m+2q+1)\\ &=(2m-2q+1)(2m+2q+1)\tag{2.3}\\ &=(2m-|j|+1)(2m+|j|+1)\\ &\,\,\color{blue}{=(2m-j+1)(2m+j+1)}\tag{2.4} \end{align*}

• In (2.2) we rearrange the $$2m-2q+1$$ terms and separate the middle term from the sum.

• In (2.3) we see the summands do not depend on the index $$k$$.

Case $$|j|=2q+1$$: This case can be calculated analogously resulting in \begin{align*} \color{blue}{\sum_{k=0}^{2m-2q-1}(4m+1-2k)}&=(2m-2q)(2m+2q+2)\\ &\,\,\color{blue}{=(2m-j+1)(2m+j+1)}\tag{2.5} \end{align*}

From (2.1),(2.4) and (2.5) we derive for $$n=2m$$:

\begin{align*} \color{blue}{\prod_{j=-2m}^{2m}}&\color{blue}{\sum_{k=0}^{2m-|j|}(4m+1-2k)}\\ &=\prod_{j=-2m}^{2m}(2m-j+1)(2m+j+1)\\ &=\prod_{j=-2m}^{2m}(2m+j+1)^2\\ &=\prod_{j=0}^{4m}(j+1)^2\\ &\,\,\color{blue}{=((4m+1)!)^2} \end{align*}

Conclusion: Both, the different rearrangements of the tables for the special case, as well as the different derivations of the general formulas rather indicate that there is no hidden relationship between the formulas in the additive and in the multiplicative case. Here it seems we have independent formulas showing us some nice properties of odd positive numbers.