(a) We claim that (a2−1,a2,a2+1,a2+2) works for a=2n+1 where n≥1. Indeed, we can verify each number in the set:
1. a2−1=(2n+1)2−1=22n+2n+1+1−1=2n+1+(2n)2
2. a2=(2n+1)2=22n+2n+1+1=2n+2+(2n−1)2
3. a2+1=(2n+1)2+1=22n+2n+1+1+1=20+a2
4. a2+2=(2n+1)2+2=22n+2n+1+1+2=21+a2
Thus, all four numbers are good, proving that there are infinitely many sets of 4 consecutive good numbers.
(b) We claim that the solutions are (1,2,3,4,5), (2,3,4,5,6), (8,9,10,11,12), (9,10,11,12,13), (288,289,290,291,292), and (289,290,291,292,293).
To prove this, we need to show that these sets are the only possible sets of 5 consecutive good numbers. We start by examining the function f(n)=(2n+1)2+3 and show that it is good if and only if n=1 or n=4.
Proof:
1. For n=1, f(1)=(21+1)2+3=32+3=9+3=12=22+22, which is good.
2. For n=4, f(4)=(24+1)2+3=172+3=289+3=292=28+62, which is good.
Now, assume n≥4 and suppose f(n) is good, i.e., (2n+1)2+3=2x+y2. This implies:
y2=22n+2n+1+4−2x
We split into cases based on the value of x:
Case 1: x≤n+1
- Subcase 1.1: x=0
y2=22n+2n+1+3=(2n+1)2+2
No two squares differ by 2, so no solutions here.
- Subcase 1.2: x=1
y2=22n+2n+1+2=(2n+1)2+1
No two squares differ by 1, so no solutions here.
- Subcase 1.3: 2≤x≤n+1
(2n)2<y2<(2n+1)2
This means there are no solutions here.
Case 2: x≥n+2
Let x=n+1+α where α≥1. We see from the equation that y is even, so let y=2z. Furthermore, let m=n−1. The equation reduces to:
z2=22m−2m(2α−1)+1
This means that z is odd and less than 2m, so let z=2m−k where k≥1 is odd. Then,
z2=22m−2m(2k)+k2
2m(2k−2α+1)=(k−1)(k+1)
We have some subcases:
- Subcase 2.1: k≡1(mod4)
2m∣(k−1)(k+1)
2m−1∣(k−1)(2k+1)
Since (k+1)/2 is odd, we have 2m−1∣k−1, so write k=1+2m−1β, where β≥0. Plugging this into the equation gives:
2mβ−2α+3=2m−2β2+β
The left side is odd, so the right side is odd. Since m=n−1≥3, β must be odd.
- Subcase 2.1.1: β=1
2m−2α+3=2m−2+1
3(2m−2+1)=2α+1
This has the unique solution m=3 and α=3. This gives n=4, which is a solution.
- Subcase 2.1.2: β=3
3⋅2m−2α+3=2m−2⋅9+3
3⋅2m−2=2α
This has no solutions.
- Subcase 2.1.3: β≥5
3−2α=2m−2(β2−4β)+β≥5⋅2m−2≥10
This has no solutions.
- Subcase 2.2: k≡3(mod4)
2m∣(k−1)(k+1)
2m−1∣(k+1)(2k−1)
Since (k−1)/2 is odd, we have 2m−1∣k+1, so write k=−1+2m−1β, where β≥1. Plugging this into the equation gives:
2mβ−2α−1=2m−2β2−β
The left side is odd, so the right side is odd. Since m=n−1≥3, β must be odd.
- Subcase 2.2.1: β=1
2m−2α−1=2m−2+1
3⋅2m−2=2α
This has no solutions.
- Subcase 2.2.2: β=3
3⋅2m−2α−1=2m−2⋅9−3
2m−2⋅3=2α−2
For the right side to be divisible by 3, we need 3∣α.
- Subcase 2.2.2.1: α=3
We get m=3, so n=4, which is a solution.
- Subcase 2.2.2.2: α≥6
The right side is 2(mod4), so we must have m=3. But this is a contradiction to size, so no solutions here.
- Subcase 2.2.3: β≥5
−1−2α=2m−2(β2−4β)−β≥2(β2−4β)−β≥5
This has no solutions.
This completes all the cases, so the only solution for n≥4 is n=4. This completes the proof of the claim. ■
Let's return to solving the original problem. We'll be needing two recurring lemmas.
Lemma: Suppose n is good. Then, n≡2(mod4) implies either n=a2+1 for odd a, or n=a2+2 for even a. Similarly, if n≡3(mod4), then n=a2+2 for odd a.
Proof: The key is that if x≥2, then 2x+y≡0,1(mod4). So if n=2x+y≡2,3(mod4), then x=0 or x=1. Working out the details of mod 4 gives the result. ■
Lemma: Suppose a2 is good where a is odd. Then either a=1, or a=2n+1 for some n≥1.
Proof: Suppose a2=2x+y2 where x≥1. Then, we have a2=2x+y2, so
(a−y)(a+y)=2x
Now, a−y≡a+y(mod2), and since x≥1, this means that they both must be even. Thus, a−y=2p and a+y=2q for some p,q≥1, so a=22p+2q. Since a is odd, this means a=2n+1 for some n≥1.
Now, if x=1, then a2=1+y2. This means y=0 and a=1, as desired. This completes the proof of the lemma. ■
Suppose that (a1,a2,a3,a4,a5) are 5 consecutive positive integers that are all good. We have 4 cases.
Case 1: Suppose a1≡0(mod4). We see that a4≡3(mod4) is good, so a4=a2+2 for some odd a. Thus, the numbers (a2−1,a2,a2+1,a2+2,a2+3) are all good. Thus, a2 is good and a odd, so a=1 or a=2n+1 for n≥1. We can't have a=1 as 12−1=0 is not good, so we must have a=2n+1. Thus, a2+3=(2n+1)2+3 is good, so by the claim, we have either n=1 or n=4. These give the two solutions:
(8,9,10,11,12)and(288,289,290,291,292)
Case 2: Suppose a1≡1(mod4). We see that a3≡3(mod4) is good, so a3=a2+2 for some odd a. Thus, the numbers (a2,a2+1,a2+2,a2+3,a2+4) are all good. Thus, a2 is good and a odd, so a=1 or a=2n+1 for n≥1. If a=1, then we get the solution:
(1,2,3,4,5)
Now suppose a=2n+1 for n≥1. Thus, a2+3=(2n+1)2+3 is good, so by the claim, we have either n=1 or n=4. These give the two solutions:
(9,10,11,12,13)and(289,290,291,292,293)
Case 3: Suppose a1≡2(mod4). Then, a2≡3(mod4) is good, so a2=a2+2 for some odd a. Thus, the numbers (a2+1,a2+2,a2+3,a2+4,a2+5) are all good. Now, a2+5≡2(mod4) is good, so by the first lemma, we have the following two subcases:
- Subcase 3.1: Suppose a2+5=b2+1 for odd b. Then, b2−a2=4, so a=0, which isn't odd.
- Subcase 3.2: Suppose a2+5=b2+2 for even b. Then, b2−a2=3, so a=1. This gives the solution:
(2,3,4,5,6)
Case 4: Suppose a1≡3(mod4). Then, a1≡3(mod4) is good, so a1=a2+2 for some odd a. Thus, the numbers (a2+2,a2+3,a2+4,a2+5,a2+6) are all good. We see that a2+6≡3(mod4) is good, so a2+6=b2+2 for odd b. Thus, b2−a2=4, so a=0, which isn't odd. So there are no solutions here.
We've shown that all the solutions must be in the claimed list, so we're done.