Difference of Squares (1)

15 can be written as the difference between two positive perfect squares: 15 = 16 1 = 4 2 1 2 . 15 = 16-1= 4^2 - 1^2. Which of the following numbers cannot be written as the difference of two positive perfect squares?

16 17 18 19 20

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

14 solutions

Arjen Vreugdenhil
Nov 13, 2017

In general, all odd positive integers, except 1, and all multiples of four, except 4 itself, may be written as the difference of non-zero perfect squares.

Thus, 18 \boxed{18} is the exception.

For the other values, we have { 16 = 5 2 3 2 17 = 9 2 8 2 19 = 1 0 2 9 2 20 = 6 2 4 2 21 = 1 1 2 1 0 2 = 5 2 2 2 \begin{cases} 16 = 5^2 - 3^2 \\ 17 = 9^2 - 8^2 \\ 19 = 10^2 - 9^2 \\ 20 = 6^2 - 4^2 \\ 21 = 11^2 - 10^2 = 5^2 - 2^2 \end{cases}


Proof: Let N N be a number and a b = N ab = N , where b > a b > a . (Such numbers a a and b b exist unless N = 1 N = 1 .)

Let d = 1 2 ( b a ) d = \tfrac12(b - a) and s = 1 2 ( b + a ) s = \tfrac12(b + a) . Then N = a b = ( s d ) ( s + d ) = s 2 d 2 . N = ab = (s - d)(s + d) = s^2 - d^2. However, if a a and b b have different parity (one is even, one is odd), then s s and d d are not integers. This situation never happens if N N is odd.

For even N N , there are two scenarios. If N N is a multiple of four, we can always choose a a and b b to be both even (unless N = 4 N =4 , because then a = b = 2 a = b = 2 ); but if N N is even but not a multiple of four, this is impossible.

Cool. I just did it with brute force.

Steve Powersuit - 3 years, 6 months ago

I am not sure why this problem rates as "intermediate" - I noted that 16, 17, 19 and 20 are all differences between two square numbers (9 + 16 = 25, 64 + 17 = 81, 81 + 19 = 100 and 16 + 20 = 36), which required a bare few seconds of thought, and like the Holmesian I am realised that once you have eliminated the impossible what remains must be the solution - 18.

Thomas Sutcliffe - 3 years, 6 months ago

Log in to reply

At this point the problem is just rated as "Level 1", where it belongs :)

Arjen Vreugdenhil - 3 years, 6 months ago

Log in to reply

I was referring to the fact that I came across it in "Problems of the Week" Intermediate. Your rating is definitely correct.

Thomas Sutcliffe - 3 years, 6 months ago

The initial question did not specify that the numbers had to be integers... If irrational numbers are used, then 18 can be represented as ({19}^0.5)^2-1^2... The root of 19 is not an integer, but it can be a squared. Given this error of omission, then all the numbers can be represented as the difference between 2 squares of any arbitrary seed number. This is a trick question and I demand a regrade...

Daniel Langstaff - 3 years, 6 months ago

Log in to reply

Perfect squares

Chris Cheek - 3 years, 6 months ago

The problem asks for "the difference of two positive perfect squares". Given that, by definition, a perfect square is the square of an integer then doesn't the problem specify that the numbers we are are squaring and then taking the difference of must be integers? Squaring the square root of 19 is not squaring an integer and so it does not give you a perfect square. Hence doing so does not abide by the rules of the game - or am I not reading your comment right?

Mads Pihl - 3 years, 6 months ago

Daniel, the problem asked for "perfect" squares. By definition, those are squares of an integer.

If you allow squares of irrational numbers, none of the five answers is correct. You do not lose points over giving no answer. :)

Arjen Vreugdenhil - 3 years, 6 months ago
Zach Abueg
Nov 26, 2017

We want to know the number of integers x x which can be written as

x = a 2 b 2 x = a^2 - b^2

where a > b a > b .

Let's break this up and look at two sets of numbers: odd and even.

If x x is an odd number, it can be written as 2 n + 1 2n + 1 . Now consider the number ( n + 1 ) 2 (n + 1)^2 , or n 2 + 2 n + 1 n^2 + 2n + 1 . We can use that to express 2 n + 1 2n + 1 in a different way.

2 n + 1 = ( n + 1 ) 2 n 2 2n + 1 = (n + 1)^2 - n^2

This proves that every odd number can be written as the difference of two squares. In fact, adjacent squares are separated by successive odd numbers.

Thus, 17 = 9 2 8 2 17 = 9^2 - 8^2 and 19 = 1 0 2 9 2 19 = 10^2 - 9^2 can be written as the difference of two positive perfect squares.

Now let's account for the even numbers. First, we know that a 2 b 2 = ( a + b ) ( a b ) a^2 - b^2 = (a + b)(a - b) . Let's consider 3 cases relating to the parity of a a and b : b: a a and b b are both even, both odd, or one of each.

Both even : : a ± b a \pm b is even, ( a + b ) ( a b ) (a + b)(a - b) is even

Both odd : : a ± b a \pm b is even, ( a + b ) ( a b ) (a + b)(a - b) is even

Even, odd : : a ± b a \pm b is odd, ( a + b ) ( a b ) (a + b)(a - b) is odd

We can ignore the last option, since we've already taken care of the odd numbers.

Any product of two even numbers has to be divisible by 4 4 - this is because the product will have at least two 2 2 s in its prime factorization. But the even numbers that cannot be evenly divided by 4 2 , 6 , 10 , 4 - 2, 6, 10, and so on - cannot be written as the product of two even numbers. These numbers therefore cannot be written in the form ( a + b ) ( a b ) , (a + b)(a - b), which also means that they cannot be written as the difference of two squares.

But is the converse - that all the even numbers divisible by 4 4 can be written as the difference of two squares - necessarily true? Yes, because if x x is a multiple of 4 , 4, it equals 4 n 4n for some number n n , and 4 n 4n can be rewritten as: ( n + 1 ) 2 ( n 1 ) 2 . (n + 1)^2 - (n - 1)^2.

Thus, 16 = 5 2 3 2 16 = 5^2 - 3^2 and 20 = 6 2 4 2 20 = 6^2 - 4^2 can be written as the difference of two positive perfect squares.

18 \boxed{18} , being neither odd or a multiple of four, cannot be written as the difference of two positive perfect squares.

Hi Zach,

I found your explanation clear and useful.

You may consider a small edit if that's possible? The original problem was set out asking for numbers that can be written as the difference between two positive perfect squares. You used 'a' and 'b' in your presentation. Unless you state that a > b, you could end up with negative products, e.g. if a = 3 and b = 5, you would get (3 + 5) (3 - 5) = - 16.

I hope this is useful to you.

Kind regards,

Dinos

Dinos Constantinou - 3 years, 6 months ago

Log in to reply

Hi Dinos! Thanks for the suggestion! I've edited it to include that condition. That's definitely a useful consideration - I appreciate your eye for detail :)

Zach Abueg - 3 years, 6 months ago
Kb E
Nov 27, 2017

x 2 0 or 1 m o d 4 a 2 b 2 0 , 1 , or 3 m o d 4 a 2 b 2 4 k + 2 a 2 b 2 18 x^2 \equiv 0 \text{ or } 1 \mod{4} \implies a^2 -b^2 \equiv 0, 1, \text{or} 3 \mod{4} \implies a^2 -b^2 \neq 4k+2 \implies a^2 -b^2 \neq 18 .

What's with the triple-line thing like = ?

Hans Kruiniger - 3 years, 6 months ago

Log in to reply

That's the equivalent sign, see here: https://brilliant.org/wiki/modular-arithmetic/

kb e - 3 years, 6 months ago

To terse an explanation. Sorry.

Desmond Campbell - 3 years, 5 months ago
Venkatachalam J
Nov 26, 2017

From the below table it is clear that 18 cannot be written as the difference of two positive perfect squares . In general, if 'N' is the number and the number can represented as factor pairs in the form (a,b). If any of its factor pair both a & b are odd numbers (or) both a & b are even numbers then the given number 'N' can written as the difference of two positive perfect squares.

N = a b = ( x + y ) ( x y ) = x 2 y 2 N=ab=(x+y) (x-y)= x^2 - y^2 , where a , b a, b are factors of N N and x = sum of a and b 2 x = \frac{\text{sum of}\ a\ \text{and}\ b}{2} , y = difference of a and b 2 y=\frac{\text{difference of}\ a\ \text{and}\ b}{2}\ . Then, the given number 'N' can written as the difference of two positive perfect squares satisfy the condition x and y must whole number iff both a and b are odd numbers (or) both a and b are even numbers.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 28 17:24:09 2017

@author: Michael Fitzgerald
"""
numbs = []
top_limit = 30

items = [x for x in range(1,top_limit+1)]
pairs = [[items[i],items[j]] for i in range(len(items)) for j in range(i+1, len(items))]

for i in pairs:
    sq_diff = i[1]**2-i[0]**2
    if sq_diff not in numbs:
        numbs.append(sq_diff)

candidates = ','.join(str(e) for e in sorted(list(set(items)-set(numbs))))

print "Numbers in range 1-%d that cannot be be formed from the difference of perfect squares: %s" \
    % (top_limit, candidates)

Numbers in range 1-30 that cannot be be formed from the difference of perfect squares: 1,2,4,6,10,14,18,22,26,30

The underlying assumption is that if N = b 2 a 2 N = b^2 - a^2 , then a , b N a,b \leq N . This would require some proof...

Arjen Vreugdenhil - 3 years, 6 months ago
Jonathan Spirit
Dec 3, 2017

Every odd integer can be expressed as the difference of perfect squares, according to a simple pattern. The difference of 1 and 4 is 3; the difference of 4 and 9 is 5; the difference of 9 and 16 is 7, and so on. We can prove this by expressing the difference of two pairs of perfect squares. n 2 ( n 1 ) 2 = n 2 n 2 + 2 n 1 = 2 n 1. ( n + 1 ) 2 n 2 = n 2 n 2 + 2 n + 1 = 2 n + 1. n^ 2 - (n - 1)^ 2 = n^ 2 - n^ 2 + 2n - 1 = 2n - 1. (n+1)^ 2 - n^ 2 = n^ 2 - n^ 2 + 2n + 1 = 2n + 1. 2n + 1 is 2 more than 2n - 1, and both express odd numbers. By math induction, if we plug in 2 for n and get 3 (which we do), we will get all subsequent odd numbers. This allows to to check off 17 and 19.

Because of this property, we know that a number is the difference of perfect squares if and only if it can be expressed as the sum of any number of consecutive odd integers. For example, 16 is the sum of 7 + 9, so we can check it off. We now only need to check 20 and 18. They must be expressed either as the sum of two or four consecutive odd integers. 20 can be expressed as 9 + 11. 18 cannot be expressed as the sum of two or four consecutive odd integers; therefore, 18 is out.

General rule for finding integer solutions for x and y where A = (x^2) - (y^2)

As long as we can show that at least ONE solution for A exists, we need not consider further solutions for the same A for the purposes of this question.

A = (x^2) - (y^2) = (x+y)(x-y) so A has the factors: (x+y) and (x-y). As we are looking for "the difference of 2 positive perfect squares", both x and y MUST be integers. A is defined as an integer, and can only be either even or odd.

Prime A:

If A is prime, then, as there are only two factors (A and 1), then, we must concede that:

x+y = A

x-y = 1

solving these simultaneous equations:

2x = (A+1)

x = (A+1)/2

so y = x-1 = (A+1)/2 - 1 = (A-1)/2

If A = the only even prime, 2,

x+y = 2

x-y = 1

2x =3

=> x=1.5 and y=0.5

As x and y are not integers, A=2 CANNOT be re-written as the difference of 2 positive perfect squares.

If A = an odd number (which will include all of the remaining, odd, primes):

let A=2k+1 where k is an integer:

x+y = 2k+1

x-y = 1

2x = (2k+1+1); x = (2k+2)/2 = k+1 (integer)

so y = x-1 = (k+1) - 1 = k (integer) so for any A = 2k+1 = (k+1+k)(k+1-k) = (k+1)^2 - k^2 = 2k+1

so for ANY odd A, it CAN be re-written as the difference of 2 positive perfect squares. There will be at least one possible solution.

All odd A?: Yes

Even A=2?: No

what about for even values of A >2 ?

Let A=2w where w is an integer. ie '2' and 'w' are factors of even A. from the above (A cannot=2) w must >=2

As above:

x+y = w

x-y = 2

2x = w+2 =>

x = (w+2)/2 = (w/2)+1

y = x-2 = (w/2)+1-2 = (w/2)-1

A = x^2 - y^2 = [(w/2)+1]^2 - [(w/2)-1]^2 = [(w/2)^2 + 2(w/2) + 1] - [(w/2)^2 - 2(w/2) + 1] = 4(w/2) = 2w = A, as expected.

BUT both x and y must be integers. (w/2) +/- 1 will only be an integer if w is EVEN. If w is even, then w=2m where m is an integer. => A = 2w = 4m

So if A is divisible by 4, then there WILL be a possible solution

From the above, it appears to show that if A=2w where w is odd, then there is no possible solution. But the above only describes the cases where x-y = 2. Given that (x+y) and (x-y) are factors of A, the same A may give several different possible factor pairs. In the case of A=2p where p is prime, (x-y) MUST = 2. So for any A=2p (p>2), there can be no solution. But what if x-y is not 2, but a larger number?

If A=2gh where g and h are prime, possible factorisations are:(1)(A), (2)(gh), (2g)(h), (2h)(g). If g and h are composite, the number of factors increases further. But we are only interested in factors where A=2w where w is odd, as we have already dealt with the case of even w.

To obtain an odd number, through multiplication, we can only have odd numbers multiplied together. Any even number introduced will make the answer even too. So if we say we have a composite ODD w, its factors, no matter how many they are, MUST also be odd.

let A=(x+y)(x-y) = (2n)(t) where both n and z are odd integers, w=nt

n and t may be prime or composite. it doesn't matter which. Here it only matters that they are odd. If A=2w and w is odd, any possible remaining solution for A, MUST have its factors in the form (2n)(t). We have already dealt with the case of 2(nt) (=2 times odd).

Either:

1) (x+y)=2n ; (x-y)=t OR

2) (x+y)=t ; (x-y)=2n

1)

x+y = 2n

x-y = t

2x = 2n+t =>

x=(2n+t)/2 = n+(t/2)

y= x-t = n+(t/2) - t = n-(t/2)

2)

x+y = t

x-y = 2n

2x = 2n+t =>

x = (2n+t)/2 = n+(t/2)

y= x-2n = n+(t/2)-2n = (t/2)-n

In both these cases x = n+(t/2) but t, from above, HAS to be odd, which as n is an integer means that x cannot be an integer, but it must be! This contradiction shows, therefore, that no possible solution exists when A=2nt, n and t both odd.

So, to summarise: If A is ODD, SOLUTIONS ARE POSSIBLE

If A is PRIME >2, ONLY ONE SOLUTION POSSIBLE: [ (A+1)/2 ]^2 - [ (A-1)/2 ]^2

If A=2: NO POSSIBLE SOLUTION

If A=2w, where w is an ODD value, NO POSSIBLE SOLUTION

If A=2w, where w is an EVEN value, (or A=4m), SOLUTIONS ARE POSSIBLE


A

16 = 4n ==> SOLUTIONS POSSIBLE [5^2 - 3^2]

17 = prime ==> ONLY ONE SOLUTION POSSIBLE [9^2 - 8^2]

18 = 2(odd number) ==> NO SOLUTION POSSIBLE <----------

19 = prime ==> ONLY ONE SOLUTION POSSIBLE [10^2 - 9^2]

20 = 4n ==> SOLUTIONS POSSIBLE [6^2 - 4^2]

Keval Vaghela
Nov 30, 2017

Firstly write down all the squares of numbers 1 to 10.
As :- 1,4,9,16,25,36,49,64,81,100. Now, 25 - 9 = 16 ; 81 - 64 = 17 ; 100 - 81 = 19 ; 36 - 16 = 20 ; Hence, we cannot write 18 as a difference of any squares of positive numbers.

How do you know that 18 18 is not the difference of squares greater than 100?

Arjen Vreugdenhil - 3 years, 6 months ago
Morgan Nasser
Nov 30, 2017

Notice from the squares 1,4,9,16... They differ by 3,5,7... This rules out all odd entries. If we observe the differences of every other square, they're the sum of neighboring odds (9-1=8=5+3 or 16-4=12=7+5). This rules out all even entries that are, after dividing by 2, even. This removes 16 and 20. Left with 18, we check for sanity it cannot be written as (2 + n) + (n) for odd n. It cannot, therefore 18 cannot be written as a difference of squares.

Chew-Seong Cheong
Nov 28, 2017

For n = a 2 b 2 n=a^2-b^2 , where n , a , b N n,a,b \in \mathbb N and a > b a>b , we have:

n = a 2 b 2 Let n = p q , where p < q are factors of n . p q = ( a b ) ( a + b ) Equating p = a b and q = a + b \begin{aligned} n & = a^2 - b^2 & \small \color{#3D99F6} \text{Let }n = pq \text{, where }p<q \text{ are factors of }n. \\ pq & = (a-b)(a+b) & \small \color{#3D99F6} \text{Equating }p = a-b \text{ and }q=a+b \end{aligned}

{ p = a b q = a + b { a = p + q 2 b = q p 2 \begin{cases} p = a-b \\ q = a+b \end{cases} \implies \begin{cases} a = \dfrac {p+q}2 \\ b = \dfrac {q-p}2 \end{cases}

Now for a a and b b to be integers, p p and q q must be either both odd or both even. Since n = p q n=pq , n n that yields solution must be either odd (when both p p and q q are odd) or a multiple of 4 (when both p p and q q are even). Since 18 is neither odd nor a multiple of 4, it cannot be expressed as a difference of two perfect squares.

Stefan Yambolov
Nov 28, 2017

The difference between the squares of N N and N + 1 N+1 is 2 N + 1 2*N+1

N square difference
1 1 3
2 4 5
3 9 7
4 16 9
5 25 11
6 36 13
7 49 15
8 64 17
9 81 19
10 100 21
... ... ...

So all odd numbers greater than 3 can be written as the difference the squares of two positive sequential numbers.

15 = 64 49 = 8 2 7 2 15=64-49=8^2-7^2

17 = 81 64 = 9 2 8 2 17=81-64=9^2-8^2

19 = 100 81 = 1 0 2 9 2 19=100-81=10^2-9^2

For even numbers you need to check if they can be written as a sum of sequential odd numbers.

16 = 7 + 9 16=7+9

that are the differences between the squares of 3 to 4 and 4 to 5. That means 16 can be written as 16 = 25 9 = 5 2 3 2 16=25-9=5^2-3^2

20 = 9 + 11 20=9+11

that are the differences between the squares of 4 to 5 and 5 to 6. That means 20 can be written as 20 = 36 16 = 6 2 4 2 20=36-16=6^2-4^2

That leaves 18 \boxed{18} as the only number in the possible answers that can't be written as a difference of two squares

(Of course some numbers can be written as a sum of more distant perfect squares, that was the case with the example)

15 = 3 + 5 + 7 15 = 3+5+7

That are the differences between the squares of 1 to 2, 2 to 3 and 3 to 4. That means 15 can be written as 15 = 16 1 = 4 2 1 2 15=16-1=4^2-1^2

32 = 5 + 7 + 9 + 11 32 = 5+7+9+11

That are the differences between the squares of 2 to 3, 3 to 2, 4 to 5 and 5 to 6. That means 32 can be written as 32 = 36 4 = 6 2 2 2 32=36-4=6^2-2^2

Stefan Yambolov - 3 years, 6 months ago
Bk Lim
Nov 28, 2017

Consider perfect squares 1,4,9.16,25,36,49 have a difference of 3,5,7,9,11,13,...

16 = 7+9 = 25 - 9

20 = 9+11 = 36 -16

18 is an even number, and it cannot be expressed as the sum of two or more consecutive odd numbers,

thus it cannot be written as the difference of two positive perfect squares.

Piers Aitman
Nov 27, 2017

We know that the difference between adjacent squares is odd, e.g. 9-4=5, 16-9=7. These differences form all positive odd numbers. This immediately discounts 17 and 19.

Consequently, the difference between non-adjacent squares is the sum of 2 or more adjacent odd numbers. We can simply see that 16=9+7 and 20=11+9.

18 is the number that can't be written like this, so for the purposes of this question, that is the answer.

It is straightforward to generalise this argument that even numbers need to be a multiple of 4 in order to be the difference between squares.

Antoine G
Nov 27, 2017

A n 2 n^2 is the sum of the n n first odd integers: n 2 = i = 1 n ( 2 i 1 ) n^2 = \sum_{i=1}^n (2i-1) So any difference of squares is a sum of consecutive odd numbers. Let's split in cases:

Case 1: there is only one odd number. Then we've got all odd numbers. (This includes 17 and 19).

Case 2: there are two consecutive odd numbers. The first possibility is 1+3 = 4. Note that the next possibility is 3+5 = 8. Successive possibilities add 4 to the whole sum. So we have all multiples of 4. (This includes 16 and 20).

Remaining cases: The sum of three consecutive odd numbers is odd, so we don't care anymore (they have the form 9 + 6 k 9 + 6k ). So we move on to 4 consecutive odd integers. The first is 16 and the next 24. At five or more consecutive odd integers we arrive at 25 or more which is too big.

PS: One could directly write ( m + k ) 2 m 2 = m 2 + 2 m k (m+k)^2-m^2 = m^2 + 2mk ( k k is then the number of consecutive odd integers). With m = 1 , 2 , 3 m = 1,2,3 or 4 4 one gets the above forms.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...