Find the total number of coefficients in the expansion of $(x^2-x +1)^{22}$ that are divisible by $6$.

Using that $(a+b+c)^3\equiv a^3+b^3+c^3\pmod 3$ repeatedly, we have, in mod $3$, $$\begin{align}&(x^2-x+1)^{22}\\\\&=(x^2-x+1)(x^2-x+1)^3((x^2-x+1)^9)^2\\\\&\equiv (x^2-x+1)(x^6-x^3+1)(x^{18}-x^9+1)^2\\\\&\equiv (x^2-x+1)(x^6-x^3+1)(x^{36}+x^{27}+x^9+1)\\\\&\equiv x^{44}-x^{43}+x^{42}-x^{41}+x^{40}-x^{39}+x^{38}-x^{37}+x^{36}+x^{35}-x^{34}+x^{33}-x^{32}+x^{31}\\\\&\qquad -x^{30}+x^{29}-x^{28}+x^{27}+x^{17}-x^{16}+x^{15}-x^{14}+x^{13}-x^{12}+x^{11}-x^{10}+x^9\\\\&\qquad +x^8-x^7+x^6-x^5+x^4-x^3+x^2-x+1\end{align}$$

It follows that the zero terms in mod $3$ are $x^{18},x^{19},x^{20},x^{21},x^{22},x^{23},x^{24},x^{25},x^{26}$.

Next, using that $(a+b+c)^2\equiv a^2+b^2+c^2\pmod 2$ repeatedly, we have, in mod $2$, $$\begin{align}&(x^2-x+1)^{22}\\\\&=(x^2-x+1)^{16}(x^2-x+1)^4(x^2-x+1)^2\\\\&\equiv (x^{32}+x^{16}+1)(x^{8}+x^4+1)(x^4+x^2+1)\\\\&\equiv x^{44}+x^{42}+x^{38}+x^{34}+x^{32}+x^{28}+x^{26}+x^{22}+x^{18}+x^{16}+x^{12}+x^{10}+x^6+x^2+1\end{align}$$

It follows that the zero terms in mod $6$ are $x^{19},x^{20},x^{21},x^{23},x^{24},x^{25}$.

Therefore, the total number of coefficients that are divisible by $6$ is $\color{red}{6}$.


You can find which coefficients are divisible by $3$ by noting that $x^2-x+1\equiv(x+1)^2\pmod{3}$ so we are seeking the coefficients of $(x+1)^{44}$ which are divisible by $3$. Now notice that:

$$(x+1)^{44}=(x+1)^{27}(x+1)^{9}(x+1)^{6}(x+1)^2\equiv (x^{27}+1)(x^9+1)(x^{6}-x^3+1)(x^2-x+1)$$

Inspection sees the zero terms are $x^{18},x^{19},x^{20},x^{24},x^{25},x^{26}$.

Of these, you need to figure out which are even. That part is a little harder.


We provide a method for determining when a binomial coefficient is a multiple of a prime $p$.

We first prove the following:

Lemma: Let $p$ be a prime and let $m,n$ be natural numbers. Let $n = lp+t$ and $m = kp+s$, where $0 \leq t < p$ and $0 \leq s < p$. Then \begin{align*} \binom{n}{m} = \binom{l}{k}\binom{t}{s}\mod p \end{align*} Proof: Observe first that for $0 < r < p$, $\binom{p}{r}$ is divisible by $p$. Hence in $$ (1+X)^p - (1+X^p) = \binom{p}{1}X + \binom{p}{2}X^2+\cdots + \binom{p}{p-1}X^{p-1} $$ all the coefficients are divisible by $p$.

Now, consider \begin{align*} P(X) &= (1+X)^{lp+t} - (1+X)^t (1+X^p)^{l} \\ &= (1+X)^t\left\{(1+X)^{lp} - (1+X^p)^l \right\} \\ &= (1+X)^t \left\{(1+X)^p - (1+X^p)\right\}\left\{(1+X)^{p(l-1)} + \cdots + (1+X^p)^{l-1}\right\} \end{align*} As observed before, $P(X)$ is a multiple of $p$.

Consider the coefficient of $X^{kp+s}$ in $P(X)$. This equals \begin{align*} \binom{lp+t}{kp+s} - \binom{t}{s}\binom{l}{k} \end{align*} and hence all the coefficients are multiples of $p$. Note that this holds even when $k = 0$ or $l=0$. This completes the proof of the lemma.

Applying the Lemma repeatedly, it follows that if \begin{align*} n &= t_1+t_2p+t_3p^2+\cdots + t_rp^{r-1} \\ m &= s_1+s_2p+s_3p^2+\cdots + s_rp^{r-1} \end{align*} then \begin{equation*} \binom{n}{m} = \binom{t_1}{s_1}\binom{t_2}{s_2}\cdots\binom{t_{r-1}}{s_{r-1}} \mod p \end{equation*} As observed, $x^2-x+1 = (x+1)^2 \pmod 3$ and hence we can find which binomials $\binom{44}{k}$ are multiples of 3.

Here, $44 = 3^3 + 3^2 + 2\cdot 3 + 2 $. If $k = s_1\cdot 3^3 + s_2 \cdot 3^2 + s_3 \cdot 3 + s_4$, where $0 \leq s_i \leq 2$, $\binom{44}{k}$ is a multiple of 3 if and only if $s_2 = 2$ and note that $s_1 \neq 2$ since $k \leq 44$. This gives that for $k = 18, 19, 20, 21, 22, 23, 24, 25, 26$, $\binom{44}{k}$ is a multiple of 3.

Of these we need to eliminate 18, 22 and 26. We do this as follows:

Since $x^2-x+1 = x^2+x+1 \pmod 2$, we have $$(x^2-x+1)^{22} = \left(\frac{1-x^3}{1-x}\right)^{22} \pmod 2$$ Again, using the Lemma we obtain upto $\mod\, 2$, $$(1-x^3)^{22} = 1 + x^6 + x^{12} + x^{18} + x^{48} + x^{54} + x^{60} + x^{66}$$ and again $mod\, 2$, $(1-x)^{-22}$ contains only even powers of $x$. Now, we eliminate $18, 22, $ and $26$ as follows:

The coefficient of $x^{18}$ is obtained by multiplying the terms containing $(1, x^{18}), (x^6, x^{12}), (x^{12}, x^6)$ and hence the coefficient is sum of three odd numbers and hence is odd.

The coefficient of $x^{22}$ is obtained by multiplying the terms containing $(1, x^{22}), (x^6, x^{16}), (x^{18}, x^4)$ and hence the coefficient is sum of three odd numbers and hence is odd.

The coefficient of $x^{26}$ is obtained by multiplying the terms containing $(1, x^{26}), (x^6, x^{20}), (x^{12}, x^{14})$ and hence the coefficient is sum of three odd numbers and hence is odd.

Thus the only coefficients that are multiples of 6 are those of $x^n$ where $n = 19, 20, 21, 23, 24, 25$.