Skip to main content
### Number and algebra

### Geometry and measure

### Probability and statistics

### Working mathematically

### For younger learners

### Advanced mathematics

# Square Difference

## You may also like

### Curvy Equation

### Digital Equation

### Euler's Totient Function

Or search by topic

Age 16 to 18

Challenge Level

- Problem
- Student Solutions
- Teachers' Resources

Nishad from Thomas Estley Community College, Dylan from Brooke Weston, Steve from Dulwich College, Ziwei (Gilbert) from Stowe School and Joshua from Bohunt Sixth Form, all in the UK, Xuan Tung from HUS High School for Gifted Students in Vietnam, Dibyadeep from Greenhill School in the USA and Rishik K expressed each of the numbers $3, 5, 8, 12$ and $16$ as the difference of two non-zero squares. This is Rishik's work:

Nishad, Dylan, Joshua, Steve, Ziwei (Gilbert), Rishik, Dibyadeep and Xuan Tung proved that any odd number can be written as the difference of two squares. This is Dylan's work:

Dylan, Dibyadeep, Joshua, Steve, Ziwei (Gilbert), Xuan Tung and Nishad proved that all numbers of the form $4k$ can be written as the difference of two squares. This is Ziwei (Gilbert)'s work, which begins with an exploration (click on the image to open a larger version):

Nishad used a very neat factorisation of $4k$ to prove the statement:

Nishad, Dylan, Joshua, Steve, Xuan Tung, Ziwei (Gilbert) and Dibyadeep all proved that no number of the form $4k+2$ can be written as the difference of two squares.

This is Dylan's proof:

Ziwei (Gilbert) and Dibyadeep thought instead about whether $a$ and $b$ (or "$x$" and "$y$") were odd or even. This is Ziwei (Gilbert)'s work (click on the images to open larger versions):

Dibyadeep went into even more possible cases:

To prove that numbers of the form $pq$ (where $p$ and $q$ are primes greater than $2$) can be written as the difference of two squares in exactly two ways, Ziwei (Gilbert) began with several investigations. This is some of Ziwei (Gilbert)'s work (click on the image to open a larger version):

Magnetoninja from the United States, Daniel from Dulwich College, Nishad, Dibyadeep, Dylan, Joshua, Steve and Ziwei (Gilbert) used this idea to prove the statement. This is Magnetoninja's work:

For integers $s$ and $t,$ WLOG (without loss of generality) let $s\gt t,$ the difference of the two squares $s^2-t^2=(s+t)(s-t).$

We claim that the two ways to write $pq$ such that it is the sum of two squares is to let $s-t=1$ and $s+t=pq,$ or to let $s-t=p$ and $s+t=q.$

Now we prove that this works for all primes $p$ and $q$ such that $p,q\gt2.$ We first consider letting $s-t=1$ and $s+t=pq.$ Substituting the first equation for $s$ in terms of $t$ into the second equation, we get $2t+1=pq.$ Note that $t$ can vary since we are only focusing on $p$ and $q,$ so it follows that $2t+1$ can be any odd number. Also, $p$ and $q$ must be odd since they are both primes greater than $2.$ This concludes the proof for our first case.

Next, we prove that $s-t=q$ and $s+t=p$ also works. Substituting the first equation for $s$ in terms of $t$ into the second equation, we obtain $q+2t=p.$ Once again, $t$ can vary so $2t$ can be any even number. Note that $p$ and $q$ are prime, therefore odd, so their difference will be an even number, proving our second case as well.

There are no more ways to write $pq$ as the difference of two squares since $p$ and $q$ are prime so $pq$ has only $4$ divisors and $2$ divisor pairs.

*Can you see where Magnetoninja's cases would go wrong if $p=2$ or $q=2$?*

Steve expressed $s$ and $t$ (or "$a$" and "$b$") in terms of $p$ and $q,$ and used this to write a clear explanation of why these results do not hold if $p$ is a prime greater than $2$ and $q=2:$

Natal from Canada started with this idea, and actually used this to answer the earlier questions. However, Natal does not find the second way to write $pq$ as the difference of two squares. Click to see Natal's work.

Xuan Tung extended the case of two primes $p$ and $q$ to any odd number that is not square. Click to see Xuan Tung's work.

Nishad, Dylan, Joshua, Daniel, Steve, Ziwei (Gilbert), Dibyadeep and Natal found the number of distinct ways in which $675$ can be written as the difference of two squares. This is Joshua's work:

Nishad, Dibyadeep, Ziwei (Gilbert), Natal and Xuan Tung showed that there are 6 ways without listing them all. This is Natal's work:

This problem asks you to use your curve sketching knowledge to find all the solutions to an equation.

Can you find a three digit number which is equal to the sum of the hundreds digit, the square of the tens digit and the cube of the units digit?

How many numbers are there less than $n$ which have no common factors with $n$?