# A cute result relating to sums of cubes

It’s well known, and easy to prove, that

$1^3+2^3+3^3+\cdots +n^3=(1+2+3+\cdots +n)^2$.

But here’s a generalization of that which has been attributed to Joseph Liouville (1809 – 1882). Pick any number, say 56, and write down all of its divisors:

$[1, 2, 4, 7, 8, 14, 28, 56]$

Now, for each number in that list, write down the number of its divisors:

$[1, 2, 3, 2, 4, 4, 6, 8]$

For example, 7 has 2 divisors (1 and 7), and 14 has 4 divisors (1, 2, 7 and 14). But for this second list, the sum of its cubes equals the square of its sum!

$1^3+2^3+3^3+2^3+4^3+4^3+6^3+8^3$

$=(1+2+3+2+4+4+6+8)^2$.

Here’s a quick check with Sage:

sage: n = 56
sage: L=[number_of_divisors(i) for i in divisors(n)];L
[1, 2, 3, 2, 4, 4, 6, 8]
sage: sum(L)^2,sum(i^3 for i in L)
(900, 900)


And now to prove this result. Start by saying that a list has the square-cube (SC) property if the sum of its cubes equals to the square of its sum. So any list $[1,2,3,\ldots,n]$ has the SC property, as does the list $[1, 2, 3, 2, 4, 4, 6, 8]$. Also define the pairwise product of two lists $A$ and $B$ to be the list $A\otimes B$ consisting of all possible products of pairs of elements from $A$ and $B$. In other words:

$A\otimes B=\{ab : \{a,b\}\in A\times B\}$

where of course $A\times B$ is the Cartesian product. From the definition then it is easy to show that,

$\displaystyle{\sum_{x\in A\otimes B}x=\bigg(\sum_{a\in A}a\bigg)\bigg(\sum_{b\in B}b\bigg)}.$

For example, if $A=[1,2,3]$ and $B=[1,2,3,4]$ then

$A\otimes B=[1,2,3,2,4,6,3,6,9,4,8,12]$

with sum 60, which is equal to the product of the sums of $A$ and $B$. Note that

$\displaystyle{\sum_{x\in A\otimes B}x = \sum_{a\in A,b\in B}ab}$

$\displaystyle{=\sum_{a\in A}\bigg(\sum_{b\in B}ab\bigg)}$

$\displaystyle{=\bigg(\sum_{a\in A}a\bigg)\bigg(\sum_{b\in B}b\bigg)}.$

It follows immediately from this that if $A$ and $B$ are two lists each of which has the SC property, then so does $A\otimes B$. To see this, suppose that

$\displaystyle{\sum_{a\in A}a^3=\bigg(\sum_{a\in A}a\bigg)^2}$

and

$\displaystyle{\sum_{b\in B}b^3=\bigg(\sum_{b\in B}b\bigg)^2}.$

Multiplying these together produces

$\displaystyle{\bigg(\sum_{a\in A}a^3\bigg)\bigg(\sum_{b\in B}b^3\bigg)=\bigg(\sum_{a\in A}a\bigg)^2\bigg(\sum_{b\in B}b\bigg)^2}$.

The right hand side is equal to

$\displaystyle{\bigg[\bigg(\sum_{a\in A}a\bigg)\bigg(\sum_{b\in B}b\bigg)\bigg]^2}$

$\displaystyle{=\bigg[\sum_{a\in A,b\in B}ab\bigg]^2}$

$\displaystyle{=\bigg(\sum_{x\in A\otimes B}x\bigg)^2}.$

By the same reasoning as above, the left hand side is equal to

$\displaystyle{\sum_{a\in A,b\in B}(ab)^3=\sum_{x\in A\otimes B}x^3.}$

By induction, if $A_i$ is a collection of lists all with the SC property, then $A_1\otimes A_2\otimes\cdots\otimes A_k$ has the SC property.

Consider $n$ and its decomposition into prime factors:

$n = p_1^{e_1}p_2^{e_2}\cdots p_k^{e_k}$.

For any prime power $m= p^e$ the number of divisors of $m$ is $e+1$; the divisors are all the powers of $p$ from 1 to $p^e$. And the numbers of divisors of all those prime powers are $[1,2,3,\ldots,e+1]$. Consider now $m = p^eq^d$. The divisors are $p^rq^s$ for all values of $r$ between 1 and $e$, and all values of $s$ between 1 and $d$. The number of divisors of $p^rq^s$ are $(r+1)(s+1)$. From this it follows that the number of divisors of the divisors of $m$ is

$[1,2,3,\ldots,e+1]\otimes [1,2,3\ldots d+1]$.

and hence which has the SC property. The general result follows by induction on the number of distinct prime factors of $n$.

Published proofs and further discussion can be found in “An Interesting Number Fact” by David Pagni, The Mathematical Gazette, Vol. 82, No. 494, Jul., 1998, and “Generalising ‘Sums of Cubes Equal to Squares of Sums'” by John Mason, The Mathematical Gazette, Vol. 85, No. 502, Mar., 2001.

1. Jeff U

Great result, but is it really a “generalization”? It’s clearly related but I don’t see the original result as a special case.

• kcrisman

Sure it’s a generalization, though not 100% obvious.

Remember, the list has to come from the number of divisors of the divisors of a number. So pick $p^n$; the divisors are exactly $[1,p,p^2,\ldots,p^n]$, so the number of divisors of each of those is $[1,2,3,\ldots,n+1]$.

What a cool result! I’ll be sure to use it the next time I teach number theory.

• kcrisman

In fact, Alasdair essentially uses this in the proof, which I should have read carefully before responding :)

Quite interesting.

3. Very nice… Think I need to take some time to wrap my head around it…thanks

4. Severus Snape

Pity it is all completely plagarised – but that is the way with most of this so called “academics” work.

• amca01

Is it really? Where from? I know the result is old, but I hadn’t seen this proof before! Please send me the links. (I haven’t actually read the articles I referenced at the end.)

• kcrisman

Snape, that’s flame-bait! I wouldn’t say plagiarized, just well-known, as amca01 himself points out.

I hadn’t seen this proof before either. As it turns out, because he didn’t use the standard $\tau$ notation for the ‘number of divisors’ function, I forgot that this is a standard ‘hard’ exercise in many number theory texts. But a nice way to present it, and nice way to introduce it for folks who are not familiar with arithmetic functions.

• Reilly

This must be some unfamiliar usage of the word “plagiarized” – the author presents a well known theorem, then a cute result that is attributed to Liouville. This is popularization, not plagiarism, bringing to light an interesting but perhaps unknown-to-the audience result. I found it interesting and learned something, thus it served its purpose for me. Plagiarism would have been if the author had claimed the result as his own, which he very clearly did not.

5. Felicity

Heh heh – sucked in my love. Severus S.xxx

6. I’m extremely pleased to uncover this web site. I need to to thank you for ones time for this particularly wonderful read!! I definitely liked every little bit of it and I have you book marked to look at new stuff on your blog.

7. John Richardson

Coming late to this party, but just wanted to add that the original “sum of the first n cubes equals the square of the sum of the first n integers” is clearly a special case of Liouville’s rule. Consider any nth power of some prime p, eg 3^4 = 81. It has five divisors, ie 81, 27, 9, 3 and 1. 27 has four divisors. 9 has three. 3 has two. And 1 has one. The rest should be obvious.