Is there an easy criterion when $\binom{n}{m}$ is divisible by $q^2$?

To analyze questions like this

On variations of Erdős squarefree conjecture: presentation and a question as a simple case

it would be nice to have a simple criterion when $\binom{n}{m}$ is divisible by $q^2$, when $q$ is a prime and $n>m>1$ integers. We can assume $2m\le n$. Maybe creating pascal's triangle modulo $q^2$ gives a structure.

Does anyone know a criterion that is easy to check without calculating the binomial coefficient ?

• Count the number of factors $q$ in both $n!$ and $m!(n-m)!$ is what I'd do – vrugtehagel Apr 5 '18 at 7:31
• @vrugtehagel And to do that, I just have to add the $p$-adic valuations with respect to $q$, right ? – Peter Apr 5 '18 at 7:32
• en.wikipedia.org/wiki/Kummer%27s_theorem – Lord Shark the Unknown Apr 5 '18 at 8:02
• Kummer's theorem - Just count the number of carries when you add $m$ to $n-m$ in base $q$. If it has two or more carries, then $q^2| \binom{n}{m}$. – achille hui Apr 5 '18 at 8:03