# the cube of integer can be written as the difference of two square

This Exercise $4$, page 7, from Burton's book Elementary Number Theory.

Prove that the cube of any integer can be written as the difference of two squares. [Hint: Notice that $n^{3}=(1^{3}+2^{3}+\cdots+n^{3})-(1^{3}+2^{3}+\cdots+(n-1)^{3}).$]

Is there a way to prove that in a more natural way?

A more natural approach is to work out exactly which integers can be written as the difference of two squares, and then notice that all cubes are such.

So suppose $n=a^2-b^2$, with $n$, $a$ and $b$ all integers. Then we have $n=(a+b)(a-b)$. Setting $x=a+b$, $y=a-b$ we have $n=xy$ with $a=\frac{x+y}{2}$, $b=\frac{x-y}{2}$. Since $a$ and $b$ are integers, $x$ and $y$ must be of the same parity.

Thus if $n$ is a different of two squares, then it can be factorized into two integers of the same parity. Either the factors are both odd, in which case $n$ is odd, or the factors are both even, in which case $n$ is divisible by $4$. Conversely, if $n$ is odd then $n=1\cdot n=\left (\frac{n+1}{2}\right)^2-\left(\frac{n-1}{2}\right)^2$, while if $n$ is divisible by $4$ then $n=2\cdot \frac{n}{2}=\left (\frac{n+4}{4}\right)^2-\left (\frac{n-4}{4}\right)^2$.

So the integers which are a difference of two squares are precisely those which are either odd or a multiple of $4$ (in other words, those not congruent to $2$ mod $4$). Since the cube of an odd number is odd and the cube of an even number is divisible by $2^3=8$ and hence by $4$, every cube is a difference of two squares.

• Very interesting approach. Feb 23 '12 at 22:20

Beni just posted the first part, see NICHOMACHUS

That is the natural answer. However, far more numbers can be represented as the difference of two squares. $$(n +1)^2 - n^2 = 2 n + 1,$$ $$(n + 1)^2 - (n - 1)^2 = 4 n.$$ Put those together, all odd numbers and all multiples of 4 can be exressed as the difference of two squares, positive or negative $n$ allowed. A cube is either odd or a multiple of 8. The only numbers that are not the difference of two squares are $2 \pmod 4,$ also written $4n+2,$ also called twice an odd number. As a result, the homework exercise works equally well with cubes replaced by fourth powers or fifth powers or higher.

• I guess I edited my answer while you posted yours. :) Feb 23 '12 at 20:14

That is the answer I know. Using the formula $$1^3+...+n^3=\left(\frac{n(n+1)}{2} \right)^2$$

There is another trick. For odd positive integers we have

$$2k+1=(k+1)^2-k^2$$

For multiples of $4$ we have

$$(k+2)^2-k^2=4(k+1)$$

Since every cube is either an odd integer either a multiple of $4$ this proves the needed result.

• I would hardly call the latter a 'trick' - the sum-of-cubes approach I would consider a bit of a trick, but the case analysis seems like the natural approach to solving a problem like this. Feb 23 '12 at 20:09

To prove it in a single equation:

$n^3 = [n(n+1)/2]^2 - [n(n-1)/2]^2$

Details here

Since the sum of the cube of the first n integers is the square of the sum of the first n integers, or:

$\sum_{i=1}^n i^3 = \left(\sum_{i=1}^n i \right) ^2$

then: $n^3 = \sum_{i=1}^n i^3 - \sum_{i=1}^{n-1} i^3 = \left(\sum_{i=1}^n i \right)^2 - \left(\sum_{i=1}^{n-1} i\right)^2$