1

Try using $\binom{n}{k} = \frac{n-k+1}{k} \binom{n}{k-1}$. To avoid issues with dividing by $k$, in case $k$ has an exponent of $p$, just keep track of the exponent of $p$ separately. For example have a cumulative tracker called pow. Now, if $p \mid n$, then replace $n$ with $n/p$ in the numerato...