#!/bin/sh set -eu PROOF=${PROOF:-/app/proof.md} mkdir -p "$(dirname -- "$PROOF")" cat > "$PROOF" <<'IMO_PROOF_c19223cf31361df927259c3d652245785bc37d9bf6c6099a2297fa59884e421a' The answer is all even $k$. Let's abbreviate $S(n):=\binom{n}{0}^{k}+\cdots+\binom{n}{n}^{k}$ for the sum in the problem. \textbf{Proof that even $k$ is necessary.} Choose $n=2$. We need $3\mid S(2)=2+2^{k}$, which requires $k$ to be even. \textbf{Proof that even $k$ is sufficient. } From now on we treat $k$ as fixed, and we let $p^{e}$ be a prime fully dividing $n+1$. It is sufficient to prove that $S(n)$ is a multiple of $p^{e}$ for each such $p^{e}$. The basic idea is to reduce from $n+1$ to $(n+1)/p$ by an induction. We prove the following lemma on each individual binomial coefficient. \textbf{Lemma. }Suppose $p^{e}$ is a prime power which fully divides $n+1$. Then \[ \binom{n}{i}\equiv\pm\binom{\frac{n+1}{p}-1}{\lfloor i/p\rfloor}\quad\left(\bmod p^{e}\right) \] \emph{Proof.} If we write \[ \binom{n}{i}=\prod_{1\leq j\leq i}\frac{n-(j-1)}{j} \] then the fractions for $p\nmid j$ are all $\pm1\left(\bmod p^{e}\right)$. So only considers those $j$ with $p\mid j$; in that case one obtains the claimed $\binom{\frac{n+1}{p}-1}{\lfloor i/p\rfloor}$ exactly (even without having to take modulo $p^{e}$). From the lemma, it follows if $p^{e}$ is a prime power which fully divides $n+1$, then \[ S(n)\equiv p\cdot S\left(\frac{n+1}{p}-1\right)\quad\left(\bmod p^{e}\right) \] by grouping the $n+1$ terms (for $0\leq i\leq n$ ) into consecutive ranges of length $p$ (by the value of $\lfloor i/p\rfloor$ ) and the result follows by induction. IMO_PROOF_c19223cf31361df927259c3d652245785bc37d9bf6c6099a2297fa59884e421a