Let $p > 2$ be a fixed prime number. Find all functions $f: \mathbb Z \to \mathbb Z_p$, where the $\mathbb Z_p$ denotes the set $\{0, 1, \ldots , p-1\}$, such that $p$ divides $f(f(n))- f(n+1) + 1$ and $f(n+p) = f(n)$ for all integers $n$.

[i]Proposed by Grant Yu[/i]
1. **Define the function and the problem constraints:**
   Let \( p > 2 \) be a fixed prime number. We need to find all functions \( f: \mathbb{Z} \to \mathbb{Z}_p \), where \( \mathbb{Z}_p \) denotes the set \( \{0, 1, \ldots, p-1\} \), such that:
   \[
   p \mid f(f(n)) - f(n+1) + 1
   \]
   and
   \[
   f(n+p) = f(n)
   \]
   for all integers \( n \).

2. **Introduce a new function \( g \):**
   Define \( g: \mathbb{Z}_p \to \mathbb{Z}_p \) such that \( g(x) \equiv f(x) \pmod{p} \). The problem constraints can be rewritten in terms of \( g \):
   \[
   g(g(n)) \equiv f(n+1) - 1 \pmod{p}
   \]
   and
   \[
   g(n+p) = g(n)
   \]
   for all \( n \in \mathbb{Z} \).

3. **Show that \( g \) is bijective:**
   Since both the domain and codomain of \( g \) are finite and equal, it suffices to show that \( g \) is surjective to prove it is bijective. For every \( k \in \text{Image}(g) \), we see that \( k-1 \) also belongs to \( \text{Image}(g) \) due to the assertion \( P(k-1) \). By induction, every \( y \in \mathbb{Z}_p \) has a number \( x \in \mathbb{Z}_p \) such that \( f(x) = y \), implying \( g \) is bijective.

4. **Induction on \( a \):**
   We claim using induction on \( a \) that \( g^{2^a}(x) = g(x+a) - a \pmod{p} \). The base case \( a = 1 \) is just \( P(x) \). Assume the result is true for some positive integer \( a \). Then:
   \[
   g^{2^{a+1}}(x) = g^{2^a}(g^{2^a}(x)) \pmod{p} = g^{2^a}(g(x+a) - a) \pmod{p} = g(g(x+a)) - a \pmod{p} = g(x+a+1) - a - 1
   \]
   which is the desired equation. By induction, this is true for all natural numbers \( a \).

5. **Analyze the periodicity of \( g \):**
   We see that \( g^{2^p} = g(n + p) \pmod{p} \). Assume \( k \) (with \( k > 2 \) for contradiction) is the smallest natural number such that \( g^k(x) = x \) for all \( x \in \mathbb{Z}_p \). Then \( k \mid 2^p - 1 \). Let \( q \) be the largest prime dividing \( k \). Since \( p \) is a prime, \( \mathrm{ord}_q(2) = p \), which is impossible if \( q < p \) because \( 2^{q-1} \equiv 1 \pmod{q} \). Thus, the largest prime dividing \( k \) exceeds \( p \), implying \( k \) exceeds \( p \).

6. **Graph decomposition:**
   Consider the graph decomposition of \( g \) as a graph \( G \), where vertices represent \( \mathbb{Z}_p \) numbers and directed edges represent \( f(v) = u \). If \( f \) were composed of cycles, \( k \) could not have a prime divisor greater than \( p \). If \( k > p \), then \( x, g(x), g(g(x)), \ldots, g^{k-1}(x) \) are all distinct, contradicting \( k > p+1 \). Thus, \( k = p + 1 \), but \( p \nmid p+1 \), and all prime divisors of \( p+1 \) do not exceed \( p \), a contradiction. Therefore, \( k \) does not have prime factors, meaning \( k = 1 \).

7. **Conclusion:**
   Since \( k = 1 \), we have \( g(x) = x \) for all \( x \in \mathbb{Z}_p \).

The final answer is \( \boxed{g(x) = x} \) for all \( x \in \mathbb{Z}_p \).