Numbers $1, 2,\ldots, n$ are written on the board. By one move, we replace some two numbers $ a, b$ with the number $a^2-b{}$. Find all $n{}$ such that after $n-1$ moves it is possible to obtain $0$.
1. **Initial Setup and Modulo 2 Analysis:**
   - We start with the numbers \(1, 2, \ldots, n\) on the board.
   - By one move, we replace two numbers \(a\) and \(b\) with \(a^2 - b\).
   - We need to determine the values of \(n\) such that after \(n-1\) moves, it is possible to obtain \(0\).

2. **Sum Modulo 2:**
   - Note that \(a^2 - b \equiv a - b \equiv a + b \pmod{2}\).
   - This implies that the sum of the numbers on the board is maintained modulo 2.
   - The sum of the first \(n\) natural numbers is \(\frac{n(n+1)}{2}\).
   - For the sum to be even, \(\frac{n(n+1)}{2} \equiv 0 \pmod{2}\).

3. **Modulo 4 Analysis:**
   - We need \(n(n+1)\) to be divisible by 4.
   - Since \(n\) and \(n+1\) are consecutive integers, one of them is even, and the product \(n(n+1)\) is always even.
   - For \(n(n+1)\) to be divisible by 4, either \(n \equiv 0 \pmod{4}\) or \(n \equiv 3 \pmod{4}\).

4. **Base Cases:**
   - **For \(n = 3\):**
     \[
     \begin{aligned}
     &1, 2, 3 \\
     &1, 2^2 - 3 = 1 \\
     &1, 1 \\
     &1^2 - 1 = 0 \\
     \end{aligned}
     \]
     Thus, it is possible to obtain 0 for \(n = 3\).

   - **For \(n = 4\):**
     \[
     \begin{aligned}
     &1, 2, 3, 4 \\
     &1, 2, 3^2 - 4 = 5 \\
     &1, 2^2 - 5 = -1 \\
     &1, -1 \\
     &(-1)^2 - 1 = 0 \\
     \end{aligned}
     \]
     Thus, it is possible to obtain 0 for \(n = 4\).

5. **Inductive Hypothesis:**
   - Assume that for \(n = 4k\) and \(n = 4k - 1\), it is possible to obtain 0 after \(n-1\) moves.

6. **Inductive Step:**
   - We need to show that it is possible to go from \(4k\) to \(4k+4\) and from \(4k-1\) to \(4k+3\).
   - Consider the sequence for \(n = 4k\):
     \[
     \begin{aligned}
     &n, n-1, n-2, n-3, \ldots \\
     &(n-1)^2 - n, n-2, n-3, \ldots \\
     &n^2 - 3n + 1, n-2, n-3, \ldots \\
     &(n-2)^2 - (n^2 - 3n + 1), n-3, \ldots \\
     &-n + 3, n-3, \ldots \\
     &(-n + 3)^2 - (n-3), \ldots \\
     &(n-3)(n-4), n-4, \ldots \\
     &(n-4)^2 - (n-3)(n-4), \ldots \\
     &n-4, \ldots \\
     \end{aligned}
     \]
     This shows that we can reduce the sequence to \(n-4\) and continue the process.

7. **Conclusion:**
   - By induction, we have shown that for \(n \equiv 0 \pmod{4}\) and \(n \equiv 3 \pmod{4}\), it is possible to obtain 0 after \(n-1\) moves.

\(\blacksquare\)

The final answer is \( \boxed{ n \equiv 0 \pmod{4} } \) and \(n \equiv 3 \pmod{4}\).