The program is incorrect as written (in that the function it calculates is not the function $F(n,k)$).
For $n=k$, $\binom{n}{k}=\binom{n}{n}=1$, so $F(n,k) = 1$. However, if you input $n=k$ both odd, then $k=0$ is false, and $(n\bmod 2 = 1)$ and $(k\bmod 2 = 1)$ are both true, so your program will return $0$ instead. It will also return $0$ incorrectly with $n$ odd and $k=1$.
As corrected, the program is now correct.
This can be seen by invoking the theorem of Kummer mentioned by Bill Dubuque:
Theorem. (Kummer) Let $p$ be a prime, and let $m$ and $n$ be integers, $0\leq n\leq m$. The exact power of $p$ that divides $\binom{m}{n}$ is the number of carries when adding $n$ and $m-n$ in base $p$.
Thus, $F(n,k)=1$ if and only if there are no carries, and $F(n,k)=0$ if and only if there is at least one carry, when adding $k$ and $n-k$ in base $2$.
If $k$ is odd and $n$ is even, then both $k$ and $n-k$ are odd, so you will have a carry in the units. Thus, if $n\equiv 0\pmod{2}$ and $k\equiv 1\pmod{2}$, then $F(n,k)=0$.
If $k$ and $n$ are both even, then so are $k$ and $n-k$; there will be a carry if and only if there is a carry after the left-most digit; i.e., if and only if there is a carry when adding $\frac{k}{2}$ and $\frac{n-k}{2}$ in base $2$. Thus, $\binom{n}{k}\equiv \binom{\frac{n}{2}}{\frac{k}{2}}\text{ if }n\equiv k\equiv 0\pmod{2}.$
Similarly, if $k$ is even and $n$ is odd, then there is no carry in the units when adding $k$ and $n-k$; so there will be a carry if and only if there is one when adding $\frac{k}{2}$ and $\frac{n-k-1}{2} = \frac{(n-1)-k}{2}$. Thus, $\binom{n}{k}\equiv\binom{\frac{n-1}{2}}{\frac{k}{2}}\text{ if }n\equiv 1\pmod{2}\text{ and }k\equiv 0\pmod{2}.$
Finally, if both $n$ and $k$ are odd, then you need to check if there is a carry when adding $\frac{k-1}{2}$ and $\frac{n-k}{2} = \frac{(n-1)-(k-1)}{2}$; this amounts to checking the parity of $\binom{\frac{n-1}{2}}{\frac{k-1}{2}}.$ This is what your program is doing, so the program returns the correct answer.