The number 21 can be written as the difference between two positive perfect squares in two different ways: { 5 2 − 2 2 1 1 2 − 1 0 2 = 2 1 = 2 1 . How many integers 1 ≤ N ≤ 1 0 0 (including the 21 shown above) can be written as the difference between two positive perfect squares in precisely two different ways?
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.
I really enjoyed working on this question. I think you should add this sequence to OEIS. It would be interesting to see what further research on it might uncover.
Mathematica
Count[Array[Length@Solve[a^2-b^2==#&&0<b<a,{a,b},Integers]&,100],2]
26
Yes, that works as well... In limiting your loop to j , k ≤ 1 0 1 you rely on the fact that if j 2 − k 2 = i > 0 then j , k < i .
In line 13, it would be more efficient to write
for(k=1;k<j;k++)
since we only look for positive differences.
Problem Loading...
Note Loading...
Set Loading...
The numbers N for which it is true are 1 5 , 2 1 , 2 4 , 2 7 , 3 2 , 3 3 , 3 5 , 3 9 , 4 0 , 5 1 , 5 5 , 5 6 , 5 7 , 6 0 , 6 4 , 6 5 , 6 9 , 7 7 , 8 1 , 8 4 , 8 5 , 8 7 , 8 8 , 9 1 , 9 3 , 9 5 .
Basically, for every factoring N = x y ( x < y ) we have N = s 2 − d 2 with s = 2 1 ( x + y ) and d = 2 1 ( y − x ) . Thus, the number of such pairs ( s , d ) is half of the number of factors of N .
Also, the number of positive factors of N = 2 a ⋅ 3 b ⋅ 5 c ⋯ is δ ( N ) = ( a + 1 ) ( b + 1 ) ( c + 1 ) ⋯ .
There are some exceptions to consider:
If x and y have opposite parity (one odd, one even), the values of s and d are not integers. Therefore, if N is even, we limit ourselves to factorings into two even numbers.
If N is a square, the factoring N = x 2 would give N = x 2 − 0 2 , and must therefore ruled out.
With this information, we tackle the possible cases.
Case Ia : None of the exceptions come into play; N is odd and not a square. Let N = 3 b ⋅ 5 c ⋅ 7 d ⋯ , then we require 2 1 ( b + 1 ) ( c + 1 ) ( d + 1 ) ⋯ = 2 i.e. ( b + 1 ) ( c + 1 ) ( d + 1 ) ⋯ = 4 . This can be accomplished in two ways:
Precisely one of the exponents b , c , d , … is equal to 3. This means that N is the cube of an odd prime number.
Precisely two of the exponents b , c , d , … are equal to 1. This means that N is the product of two district odd primes .
Case Ib : N is an odd square. Let N = 3 2 β ⋅ 5 2 γ ⋅ 7 2 δ ⋯ , then we find (after ruling out the factor N ): ( 2 β + 1 ) ( 2 γ + 1 ) ( 2 δ + 1 ) ⋯ = 5 . This requires that one of 2 β , 2 γ , 2 δ , … is 4; in other words, N is the fourth power of an odd prime .
Case II : N is even. Since we require the factors x , y to be even, we might as well work with N ′ = x ′ y ′ , where N ′ = N / 4 , x ′ = x / 2 and y ′ = y / 2 . Thus we are back to case I, except now we allow 2 as a prime factor and multiply each number we find by 4. Thus:
case Ia(i) Ia(ii) Ib IIa(i) IIa(ii) IIb form p 3 p q p 4 4 ⋅ 2 3 4 ⋅ p 3 4 ⋅ 2 q 4 ⋅ p q 4 ⋅ 2 4 4 ⋅ p 4 values of N up to 100 2 7 1 5 , 2 1 , 3 3 , 3 9 , 5 1 , 5 7 , 6 9 , 8 7 , 9 3 3 5 , 5 5 , 6 5 , 8 5 , 9 5 7 7 , 9 1 8 1 3 2 − 2 4 , 4 0 , 5 6 , 8 8 6 0 , 8 4 6 4 −
A complete list of the 26 solutions and the two ways to write each as a difference of squares:
N 1 5 2 1 2 4 2 7 3 2 3 3 3 5 3 9 4 0 5 1 5 5 5 6 5 7 6 0 6 4 6 5 6 9 7 7 8 1 8 4 8 5 8 7 8 8 9 1 9 3 9 5 8 2 − 7 2 1 1 2 − 1 0 2 7 2 − 5 2 1 4 2 − 1 3 2 9 2 − 7 2 1 7 2 − 1 6 2 1 8 2 − 1 7 2 2 0 2 − 1 9 2 1 1 2 − 9 2 2 6 2 − 2 5 2 2 8 2 − 2 7 2 1 5 2 − 1 3 2 2 9 2 − 2 8 2 1 6 2 − 1 4 2 1 7 2 − 1 5 2 3 3 2 − 3 2 2 3 5 2 − 3 4 2 3 9 2 − 3 8 2 4 1 2 − 4 0 2 2 2 2 − 2 0 2 4 3 2 − 4 2 2 4 4 2 − 4 3 2 2 3 2 − 2 1 2 4 6 2 − 4 5 2 4 7 2 − 4 6 2 4 8 2 − 4 7 2 4 2 − 1 2 5 2 − 2 2 5 2 − 1 2 6 2 − 3 2 6 2 − 2 2 7 2 − 4 2 6 2 − 1 2 8 2 − 5 2 7 2 − 3 2 1 0 2 − 7 2 8 2 − 3 2 9 2 − 5 2 1 1 2 − 8 2 8 2 − 2 2 1 0 2 − 6 2 9 2 − 4 2 1 3 2 − 1 0 2 9 2 − 2 2 1 5 2 − 1 2 2 1 0 2 − 4 2 1 1 2 − 6 2 1 6 2 − 1 3 2 1 3 2 − 9 2 1 0 2 − 3 2 1 7 2 − 1 4 2 1 2 2 − 7 2