Suppose that positive integers $m,n,k$ satisfy the equations $$m^2+1=2n^2, 2m^2+1=11k^2.$$ Find the residue when $n$ is divided by $17$.
1. We start with the given equations:
   \[
   m^2 + 1 = 2n^2
   \]
   \[
   2m^2 + 1 = 11k^2
   \]

2. We need to find the residue of \( n \) when divided by 17. First, we note that the solution \((k, m, n) = (3, 7, 5)\) satisfies both equations:
   \[
   7^2 + 1 = 49 + 1 = 50 = 2 \cdot 25 = 2 \cdot 5^2
   \]
   \[
   2 \cdot 7^2 + 1 = 2 \cdot 49 + 1 = 98 + 1 = 99 = 11 \cdot 9 = 11 \cdot 3^2
   \]

3. We claim that other residues are impossible. To prove this, we recursively define the sequences \(\{m_i\}_{i=1}^\infty\) and \(\{n_i\}_{i=1}^\infty\) as follows:
   \[
   m_1 = n_1 = 1, \quad m_{i+1} = 3m_i + 4n_i, \quad n_{i+1} = 2m_i + 3n_i \quad (i \ge 1)
   \]

4. By a well-known lemma on Pell equations, we know that \((m, n) = (m_j, n_j)\) for some \(j \ge 1\). We need to check the residues of \(n\) modulo 11 and 17.

5. First, we check \(n\) modulo 11. We know that \(n^2 \equiv 3 \pmod{11}\), which implies \(n \equiv \pm 5 \pmod{11}\). We check the sequence \((m_i, n_i)\) modulo 11:
   \[
   (1, 1) \rightarrow (7, 5) \rightarrow (8, 7) \rightarrow (8, 4) \rightarrow (7, 6) \rightarrow (1, -1) \rightarrow (-1, -1) \rightarrow (-7, -5) \rightarrow (-8, -7) \rightarrow (-8, -4) \rightarrow (-7, 5) \rightarrow (-1, 1) \rightarrow (1, 1) \rightarrow \dots
   \]
   This implies \(j \equiv 2 \pmod{3}\).

6. Next, we check \(n\) modulo 17. We observe the sequence \((m_i, n_i)\) modulo 17:
   \[
   (1, 1) \rightarrow (7, 5) \rightarrow (7, 12) \rightarrow (1, -1) \rightarrow (-1, -1) \rightarrow (-7, 12) \rightarrow (-7, 5) \rightarrow (-1, 1) \rightarrow (1, 1) \rightarrow \dots
   \]
   This sequence does not provide direct information about \(n\) modulo 17.

7. We use the equation \((2n-1)(2n+1) = 4n^2 - 1 = 11k^2\). Since \(2n-1\) and \(2n+1\) are positive, we consider two cases:
   \[
   \begin{cases}
   2n-1 = 11u^2 \\
   2n+1 = v^2
   \end{cases}
   \quad \text{or} \quad
   \begin{cases}
   2n+1 = 11u^2 \\
   2n-1 = v^2
   \end{cases}
   \]

8. For the first case, \(11u^2 + 2 = v^2\), which is a contradiction since \(\left(\frac{2}{11}\right) = -1\).

9. For the second case, \(2n-1 = v^2\) and \(2n+1 = 11u^2\). This implies \(n \equiv 5 \pmod{11}\). Hence, \(j \equiv 2, 11 \pmod{12}\), or \(j \equiv 2, 3 \pmod{4}\). This leads to \(n \equiv \pm 5 \pmod{17}\).

10. We need to prove that \(n \equiv -5 \pmod{17}\) is impossible. If \(n \equiv -5 \pmod{17}\), then \(v^2 = 2n - 1 \equiv 6 \pmod{17}\). However, \(\left(\frac{6}{17}\right) = -1\), which is a contradiction.

Therefore, the only possible residue is \(n \equiv 5 \pmod{17}\).

The final answer is \(\boxed{5}\)