$f$ is a polynomial of degree $n$ with integer coefficients and $f(x)=x^2+1$ for $x=1,2,\cdot ,n$. What are the possible values for $f(0)$?
1. **Define the polynomial and the function \( g(x) \):**
   Given that \( f \) is a polynomial of degree \( n \) with integer coefficients and \( f(x) = x^2 + 1 \) for \( x = 1, 2, \ldots, n \), we define the function \( g(x) = f(x) - (x^2 + 1) \). Since \( f(x) = x^2 + 1 \) for \( x = 1, 2, \ldots, n \), it follows that \( g(x) = 0 \) for \( x = 1, 2, \ldots, n \).

2. **Express \( g(x) \) in terms of its roots:**
   Since \( g(x) \) is a polynomial of degree \( n \) and has roots at \( x = 1, 2, \ldots, n \), we can write \( g(x) \) as:
   \[
   g(x) = A \prod_{i=1}^{n} (x - i)
   \]
   for some integer \( A \).

3. **Express \( f(x) \) in terms of \( g(x) \):**
   Substituting \( g(x) \) back into the expression for \( f(x) \), we get:
   \[
   f(x) = g(x) + (x^2 + 1) = A \prod_{i=1}^{n} (x - i) + x^2 + 1
   \]

4. **Calculate \( f(0) \):**
   To find \( f(0) \), we substitute \( x = 0 \) into the expression for \( f(x) \):
   \[
   f(0) = A \prod_{i=1}^{n} (0 - i) + 0^2 + 1 = A \prod_{i=1}^{n} (-i) + 1 = A (-1)^n n! + 1
   \]
   Therefore, the possible values for \( f(0) \) are:
   \[
   f(0) = A (-1)^n n! + 1
   \]

5. **Special cases for \( n = 1 \) and \( n = 2 \):**
   - For \( n = 1 \):
     \[
     f(1) = 2 \implies f(x) = a(x - 1) + 2
     \]
     Substituting \( x = 0 \):
     \[
     f(0) = a(0 - 1) + 2 = 2 - a
     \]
     Since \( a \) can be any integer, \( f(0) \) can be any integer.

   - For \( n = 2 \):
     If \( g(x) \) is the zero polynomial, then \( f(x) = x^2 + 1 \), and:
     \[
     f(0) = 0^2 + 1 = 1
     \]
     Otherwise, \( g(x) = A(x - 1)(x - 2) \), and:
     \[
     f(x) = A(x - 1)(x - 2) + x^2 + 1
     \]
     Substituting \( x = 0 \):
     \[
     f(0) = A(0 - 1)(0 - 2) + 0^2 + 1 = 2A + 1
     \]
     Therefore, \( f(0) \) can be \( 1 \) or \( 2A + 1 \) for any integer \( A \).

The final answer is \( \boxed{ A (-1)^n n! + 1 } \) for \( n > 2 \), any integer for \( n = 1 \), and \( 1 \) or \( 2A + 1 \) for \( n = 2 \).