Prove that,
- f(x)=0 when k is not prime
- f(x)=1 when k is prime
- N.B: Here f(x)= a mod k means the reminder we get by dividing 'a' by 'k'
I found that the statements are right by testing those. But I am not understanding how to prove that. So, I need help.

Hint:
Every term in $a$ is the ratio of $(2k-1!)$ over an integer $i\in[1,2k-1]$. Hence taking the modulo $k$, all terms vanish, but
$$\frac{(2k-1)!}k=1\cdot2\cdots(k-1)\cdot(k+1)\cdots(2k-1).$$
If $k$ is composite, the above product will contain the factors of $k$, and the modulo also vanishes.
Remains to prove the value $1$ for a prime. (Wilson's theorem.)