Call a number $n$ [i]good[/i] if it can be expressed as $2^x+y^2$ for where $x$ and $y$ are nonnegative integers.
(a) Prove that there exist infinitely many sets of $4$ consecutive good numbers.
(b) Find all sets of $5$ consecutive good numbers.

[i]Proposed by Michael Ma[/i]
(a) We claim that \((a^2-1, a^2, a^2+1, a^2+2)\) works for \(a = 2^n + 1\) where \(n \ge 1\). Indeed, we can verify each number in the set:

1. \(a^2 - 1 = (2^n + 1)^2 - 1 = 2^{2n} + 2^{n+1} + 1 - 1 = 2^{n+1} + (2^n)^2\)
2. \(a^2 = (2^n + 1)^2 = 2^{2n} + 2^{n+1} + 1 = 2^{n+2} + (2^n - 1)^2\)
3. \(a^2 + 1 = (2^n + 1)^2 + 1 = 2^{2n} + 2^{n+1} + 1 + 1 = 2^0 + a^2\)
4. \(a^2 + 2 = (2^n + 1)^2 + 2 = 2^{2n} + 2^{n+1} + 1 + 2 = 2^1 + a^2\)

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) = (2^n + 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) = (2^1 + 1)^2 + 3 = 3^2 + 3 = 9 + 3 = 12 = 2^2 + 2^2\), which is good.
2. For \(n = 4\), \(f(4) = (2^4 + 1)^2 + 3 = 17^2 + 3 = 289 + 3 = 292 = 2^8 + 6^2\), which is good.

Now, assume \(n \ge 4\) and suppose \(f(n)\) is good, i.e., \((2^n + 1)^2 + 3 = 2^x + y^2\). This implies:
\[
y^2 = 2^{2n} + 2^{n+1} + 4 - 2^x
\]

We split into cases based on the value of \(x\):

**Case 1:** \(x \le n + 1\)
- **Subcase 1.1:** \(x = 0\)
  \[
  y^2 = 2^{2n} + 2^{n+1} + 3 = (2^n + 1)^2 + 2
  \]
  No two squares differ by 2, so no solutions here.

- **Subcase 1.2:** \(x = 1\)
  \[
  y^2 = 2^{2n} + 2^{n+1} + 2 = (2^n + 1)^2 + 1
  \]
  No two squares differ by 1, so no solutions here.

- **Subcase 1.3:** \(2 \le x \le n + 1\)
  \[
  (2^n)^2 < y^2 < (2^n + 1)^2
  \]
  This means there are no solutions here.

**Case 2:** \(x \ge n + 2\)
Let \(x = n + 1 + \alpha\) where \(\alpha \ge 1\). We see from the equation that \(y\) is even, so let \(y = 2z\). Furthermore, let \(m = n - 1\). The equation reduces to:
\[
z^2 = 2^{2m} - 2^m(2^\alpha - 1) + 1
\]
This means that \(z\) is odd and less than \(2^m\), so let \(z = 2^m - k\) where \(k \ge 1\) is odd. Then,
\[
z^2 = 2^{2m} - 2^m(2k) + k^2
\]
\[
2^m(2k - 2^\alpha + 1) = (k - 1)(k + 1)
\]

We have some subcases:

- **Subcase 2.1:** \(k \equiv 1 \pmod{4}\)
  \[
  2^m \mid (k - 1)(k + 1)
  \]
  \[
  2^{m-1} \mid (k - 1)(\frac{k + 1}{2})
  \]
  Since \((k + 1)/2\) is odd, we have \(2^{m-1} \mid k - 1\), so write \(k = 1 + 2^{m-1}\beta\), where \(\beta \ge 0\). Plugging this into the equation gives:
  \[
  2^m\beta - 2^\alpha + 3 = 2^{m-2}\beta^2 + \beta
  \]
  The left side is odd, so the right side is odd. Since \(m = n - 1 \ge 3\), \(\beta\) must be odd.

  - **Subcase 2.1.1:** \(\beta = 1\)
    \[
    2^m - 2^\alpha + 3 = 2^{m-2} + 1
    \]
    \[
    3(2^{m-2} + 1) = 2^\alpha + 1
    \]
    This has the unique solution \(m = 3\) and \(\alpha = 3\). This gives \(n = 4\), which is a solution.

  - **Subcase 2.1.2:** \(\beta = 3\)
    \[
    3 \cdot 2^m - 2^\alpha + 3 = 2^{m-2} \cdot 9 + 3
    \]
    \[
    3 \cdot 2^{m-2} = 2^\alpha
    \]
    This has no solutions.

  - **Subcase 2.1.3:** \(\beta \ge 5\)
    \[
    3 - 2^\alpha = 2^{m-2}(\beta^2 - 4\beta) + \beta \ge 5 \cdot 2^{m-2} \ge 10
    \]
    This has no solutions.

- **Subcase 2.2:** \(k \equiv 3 \pmod{4}\)
  \[
  2^m \mid (k - 1)(k + 1)
  \]
  \[
  2^{m-1} \mid (k + 1)(\frac{k - 1}{2})
  \]
  Since \((k - 1)/2\) is odd, we have \(2^{m-1} \mid k + 1\), so write \(k = -1 + 2^{m-1}\beta\), where \(\beta \ge 1\). Plugging this into the equation gives:
  \[
  2^m\beta - 2^\alpha - 1 = 2^{m-2}\beta^2 - \beta
  \]
  The left side is odd, so the right side is odd. Since \(m = n - 1 \ge 3\), \(\beta\) must be odd.

  - **Subcase 2.2.1:** \(\beta = 1\)
    \[
    2^m - 2^\alpha - 1 = 2^{m-2} + 1
    \]
    \[
    3 \cdot 2^{m-2} = 2^\alpha
    \]
    This has no solutions.

  - **Subcase 2.2.2:** \(\beta = 3\)
    \[
    3 \cdot 2^m - 2^\alpha - 1 = 2^{m-2} \cdot 9 - 3
    \]
    \[
    2^{m-2} \cdot 3 = 2^\alpha - 2
    \]
    For the right side to be divisible by 3, we need \(3 \mid \alpha\).

    - **Subcase 2.2.2.1:** \(\alpha = 3\)
      We get \(m = 3\), so \(n = 4\), which is a solution.

    - **Subcase 2.2.2.2:** \(\alpha \ge 6\)
      The right side is \(2 \pmod{4}\), so we must have \(m = 3\). But this is a contradiction to size, so no solutions here.

  - **Subcase 2.2.3:** \(\beta \ge 5\)
    \[
    -1 - 2^\alpha = 2^{m-2}(\beta^2 - 4\beta) - \beta \ge 2(\beta^2 - 4\beta) - \beta \ge 5
    \]
    This has no solutions.

This completes all the cases, so the only solution for \(n \ge 4\) is \(n = 4\). This completes the proof of the claim. \(\blacksquare\)

Let's return to solving the original problem. We'll be needing two recurring lemmas.

**Lemma:** Suppose \(n\) is good. Then, \(n \equiv 2 \pmod{4}\) implies either \(n = a^2 + 1\) for odd \(a\), or \(n = a^2 + 2\) for even \(a\). Similarly, if \(n \equiv 3 \pmod{4}\), then \(n = a^2 + 2\) for odd \(a\).

**Proof:** The key is that if \(x \ge 2\), then \(2^x + y \equiv 0, 1 \pmod{4}\). So if \(n = 2^x + y \equiv 2, 3 \pmod{4}\), then \(x = 0\) or \(x = 1\). Working out the details of mod \(4\) gives the result. \(\blacksquare\)

**Lemma:** Suppose \(a^2\) is good where \(a\) is odd. Then either \(a = 1\), or \(a = 2^n + 1\) for some \(n \ge 1\).

**Proof:** Suppose \(a^2 = 2^x + y^2\) where \(x \ge 1\). Then, we have \(a^2 = 2^x + y^2\), so
\[
(a - y)(a + y) = 2^x
\]
Now, \(a - y \equiv a + y \pmod{2}\), and since \(x \ge 1\), this means that they both must be even. Thus, \(a - y = 2^p\) and \(a + y = 2^q\) for some \(p, q \ge 1\), so \(a = \frac{2^p + 2^q}{2}\). Since \(a\) is odd, this means \(a = 2^n + 1\) for some \(n \ge 1\).

Now, if \(x = 1\), then \(a^2 = 1 + y^2\). This means \(y = 0\) and \(a = 1\), as desired. This completes the proof of the lemma. \(\blacksquare\)

Suppose that \((a_1, a_2, a_3, a_4, a_5)\) are 5 consecutive positive integers that are all good. We have 4 cases.

**Case 1:** Suppose \(a_1 \equiv 0 \pmod{4}\). We see that \(a_4 \equiv 3 \pmod{4}\) is good, so \(a_4 = a^2 + 2\) for some odd \(a\). Thus, the numbers \((a^2 - 1, a^2, a^2 + 1, a^2 + 2, a^2 + 3)\) are all good. Thus, \(a^2\) is good and \(a\) odd, so \(a = 1\) or \(a = 2^n + 1\) for \(n \ge 1\). We can't have \(a = 1\) as \(1^2 - 1 = 0\) is not good, so we must have \(a = 2^n + 1\). Thus, \(a^2 + 3 = (2^n + 1)^2 + 3\) is good, so by the claim, we have either \(n = 1\) or \(n = 4\). These give the two solutions:
\[
\boxed{(8, 9, 10, 11, 12) \quad \text{and} \quad (288, 289, 290, 291, 292)}
\]

**Case 2:** Suppose \(a_1 \equiv 1 \pmod{4}\). We see that \(a_3 \equiv 3 \pmod{4}\) is good, so \(a_3 = a^2 + 2\) for some odd \(a\). Thus, the numbers \((a^2, a^2 + 1, a^2 + 2, a^2 + 3, a^2 + 4)\) are all good. Thus, \(a^2\) is good and \(a\) odd, so \(a = 1\) or \(a = 2^n + 1\) for \(n \ge 1\). If \(a = 1\), then we get the solution:
\[
\boxed{(1, 2, 3, 4, 5)}
\]
Now suppose \(a = 2^n + 1\) for \(n \ge 1\). Thus, \(a^2 + 3 = (2^n + 1)^2 + 3\) is good, so by the claim, we have either \(n = 1\) or \(n = 4\). These give the two solutions:
\[
\boxed{(9, 10, 11, 12, 13) \quad \text{and} \quad (289, 290, 291, 292, 293)}
\]

**Case 3:** Suppose \(a_1 \equiv 2 \pmod{4}\). Then, \(a_2 \equiv 3 \pmod{4}\) is good, so \(a_2 = a^2 + 2\) for some odd \(a\). Thus, the numbers \((a^2 + 1, a^2 + 2, a^2 + 3, a^2 + 4, a^2 + 5)\) are all good. Now, \(a^2 + 5 \equiv 2 \pmod{4}\) is good, so by the first lemma, we have the following two subcases:

- **Subcase 3.1:** Suppose \(a^2 + 5 = b^2 + 1\) for odd \(b\). Then, \(b^2 - a^2 = 4\), so \(a = 0\), which isn't odd.

- **Subcase 3.2:** Suppose \(a^2 + 5 = b^2 + 2\) for even \(b\). Then, \(b^2 - a^2 = 3\), so \(a = 1\). This gives the solution:
\[
\boxed{(2, 3, 4, 5, 6)}
\]

**Case 4:** Suppose \(a_1 \equiv 3 \pmod{4}\). Then, \(a_1 \equiv 3 \pmod{4}\) is good, so \(a_1 = a^2 + 2\) for some odd \(a\). Thus, the numbers \((a^2 + 2, a^2 + 3, a^2 + 4, a^2 + 5, a^2 + 6)\) are all good. We see that \(a^2 + 6 \equiv 3 \pmod{4}\) is good, so \(a^2 + 6 = b^2 + 2\) for odd \(b\). Thus, \(b^2 - a^2 = 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.