<s>[INST] Binomial coefficients $\binom{n}{b} \pmod{n}$, $n > b$, $n$ odd, $n,b$ positive integers, AKS test I am looking at the values of Binomial coefficients $\binom{n}{b}  \pmod{n}$, where $n > b$, $n$ odd, and $n,b$ positive integers. I am planning to use the results in an implementation in python of the AKS primality test.
Examples of binimial coeffs mod $n$:


*

*$b=3, n=5$, $$\binom{5}{3}  \pmod{5} \cong 0$$

*$b=10, n=15$, $$\binom{15}{10}  \pmod{15} \cong 3$$
Since it is mentioned in comments, Lucas's theorem is for $n$ prime, but I am considering odd $n$.
I have found that there are several patterns, that I think may depend on the factorisation of $b$
Examples of patterns found (using assumptions stated):


*

*For $b=6$: 


$\binom{n}{6} \pmod{n} \cong \frac{n}{3}$ when $n \pmod{3} \cong 0$ and $n \pmod{9} \cong 0$
$\binom{n}{6} \pmod{n} \cong \frac{2n}{3}$ when $n \pmod{3} \cong 0$ and $n \pmod{9} \cong 6$
$\binom{n}{6} \pmod{n} \cong 0$ when $n \pmod{3}$ is not cong to $0$


*For $b=7$: 


$\binom{n}{7} \pmod{n} = \frac{n}{7}$ when $n \pmod{7} \cong 0$
$\binom{n}{7} \pmod{n} = 0$ when $n \pmod{7} $ not cong to $0$


*For $b=8$: 


$\binom{n}{8} \pmod{n} \cong 0$
Questions:


*

*What is the relationship between $\binom{n}{b} \pmod{n}$ and $b$ for odd $n$?

*Seeking reference requests.
 [/INST] As a consequence of theorem 4 in


*

*Andrew D. Loveless: A Congruence for Products of Binomial Coefﬁcients modulo a Composite, in: INTEGERS 7 (A44 10 Jan 2007)


we have $\binom{n}{b}\equiv 0\pmod{n}$ if (but not only if) $\gcd(n,b)=1$. The other theorems and corollaries in the paper may be of interest to you as well.
</s>