Can this primality test be optimized to runs in polynomial time? Theorem :
Let $k$  be positive integer such that : $k \in [1,\lfloor \sqrt p \rfloor ]$
$\binom{p}{k} \equiv 0 \pmod p$ for all $k$ iff $p$ is a prime number .

Test written in Maple :

Test is general , unconditional , deterministic but it runs in exponential time .
Can it be optimized to runs in polynomial time ?
As a first optimization you could keep the current value of the binomial each time and update it with a multiplication and a division rather than recomputing at each step.

As a next optimization you might realize that each division is exact, so you can use Jebelean-Krandick bidirectional division.

Then you might realize that each step essentially tests if k divides p, and so replace the binomial calculation with a modulus test.

Then you could run the test over only the primes k up to $\sqrt p$.

So after all these optimizations, you are left with trial division, which runs in exponential time.
You can use dynamic programming I mean instead of compute binomial(p,k) in each loop use this one : temp := temp * (p - k+1) / k;. and at the start of the program set temp to 1

I used this fact : binomial(p,k) = binomial(p,k-1) * (p-k+1) / k.