Let $a\in\mathbb{R}-\{0\}$. Find all functions $f: \mathbb{R}\to\mathbb{R}$ such that $f(a+x) = f(x) - x$ for all $x\in\mathbb{R}$.

[i]Dan Schwartz[/i]
1. Given the functional equation \( f(a + x) = f(x) - x \), we aim to find all functions \( f: \mathbb{R} \to \mathbb{R} \) that satisfy this equation.
2. Define a new function \( g(x) = f(x) - \frac{x^2}{2a} + \frac{x}{2} \). We will show that \( g(a + x) = g(x) \).
3. Start by substituting \( g(a + x) \):
   \[
   g(a + x) = f(a + x) - \frac{(a + x)^2}{2a} + \frac{a + x}{2}
   \]
4. Using the given functional equation \( f(a + x) = f(x) - x \), substitute \( f(a + x) \):
   \[
   g(a + x) = f(x) - x - \frac{a^2 + 2ax + x^2}{2a} + \frac{a + x}{2}
   \]
5. Simplify the quadratic term:
   \[
   g(a + x) = f(x) - x - \frac{a^2}{2a} - \frac{2ax}{2a} - \frac{x^2}{2a} + \frac{a}{2} + \frac{x}{2}
   \]
6. Further simplification:
   \[
   g(a + x) = f(x) - x - \frac{a}{2} - x - \frac{x^2}{2a} + \frac{a}{2} + \frac{x}{2}
   \]
7. Combine like terms:
   \[
   g(a + x) = f(x) - x - \frac{x^2}{2a} + \frac{x}{2}
   \]
8. Notice that:
   \[
   g(a + x) = f(x) - \frac{x^2}{2a} + \frac{x}{2} - x
   \]
9. Recognize that:
   \[
   g(a + x) = g(x) - x
   \]
10. Since \( g(a + x) = g(x) \), \( g(x) \) must be a periodic function with period \( a \). The only continuous periodic functions are constants. Therefore, \( g(x) = C \) for some constant \( C \).
11. Substitute back to find \( f(x) \):
    \[
    f(x) = g(x) + \frac{x^2}{2a} - \frac{x}{2} = C + \frac{x^2}{2a} - \frac{x}{2}
    \]
12. Therefore, the general solution for \( f(x) \) is:
    \[
    f(x) = C + \frac{x^2}{2a} - \frac{x}{2}
    \]

The final answer is \( \boxed{ f(x) = C + \frac{x^2}{2a} - \frac{x}{2} } \).