How many positive integers from 1 to 2018 cannot be expressed as the difference between two perfect squares?
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.
If a positive integer x can be written as a difference between two perfect squares, say x = a 2 − b 2 , then x = ( a + b ) ( a − b ) . It's obvious that a + b and a − b has the same parity.
If they are both even, then x is divisible by 4 .
If they are both odd, then x is odd.
So x cannot be expressed as a difference between two perfect squares if and only if x has a remainder of 2 when divided by 4 .
From 1 to 2 0 1 8 , such numbers are 2 , 6 , 1 0 , . . . , 2 0 1 8 . Thus our answer is 4 2 0 1 8 − 2 + 1 = 5 0 5