TAOCP 7.2.1.2 Exercise 62
Let $q$ be a primitive $m$th root of unity, so $q^m=1$ and $1+q+\cdots+q^{m-1}=0$.
Section 7.2.1.2: Generating All Permutations
Exercise 62. ▶ [M23] [M23] What permutations can be reached as the final element of a Gray code that starts at 12 . . . n?
Verified: no
Solve time: 5m
Solution
Let $q$ be a primitive $m$th root of unity, so $q^m=1$ and $1+q+\cdots+q^{m-1}=0$. Define the Gaussian binomial coefficient
$$ \binom{n}{k}_q=\frac{(1-q^n)(1-q^{n-1})\cdots(1-q^{n-k+1})}{(1-q)(1-q^2)\cdots(1-q^k)}. $$
Write integers in base $m$ as
$$ n = m a + r,\quad 0 \le r < m, $$
$$ k = m b + s,\quad 0 \le s < m, $$
where $a=\lfloor n/m\rfloor$, $b=\lfloor k/m\rfloor$, $r=n \bmod m$, $s=k \bmod m$.
Split the product defining $\binom{n}{k}_q$ into blocks of size $m$:
$$ {1-q^j : 1 \le j \le n} = \bigcup_{t=0}^{a-1} {1-q^{tm+u} : 1 \le u \le m} \cup {1-q^{am+u} : 1 \le u \le r}. $$
For $0 \le u \le m-1$,
$$ q^{tm+u} = (q^m)^t q^u = q^u, $$
so each full block satisfies
$$ \prod_{u=1}^{m} (1-q^{tm+u}) = \prod_{u=1}^{m} (1-q^u). $$
Since $q$ is primitive, $1-q^u \neq 0$ for $1 \le u \le m-1$ and $1-q^m=0$. Hence each full block contains exactly one vanishing factor, namely $1-q^{tm+m}=1-q^{(t+1)m}=0$, so every block of length $m$ contributes a zero factor to the numerator and denominator in the same structured way inside the Gaussian binomial coefficient. The standard factorization for cyclotomic specialization isolates the nonvanishing part by removing exactly those factors indexed by multiples of $m$.
More explicitly, among the factors $1-q^j$ in the numerator, those with $j \equiv 0 \pmod m$ contribute zeros; the same occurs in the denominator. After cancellation of corresponding vanishing factors in matching numerator and denominator blocks, the remaining nonzero contributions come only from indices $j \not\equiv 0 \pmod m$.
Thus the product decomposes into two independent parts:
- Indices of the form $tm+u$ with $1 \le u \le m-1$, which contribute a factor independent of $t$ after using $q^{tm+u}=q^u$.
- Indices divisible by $m$, which contribute the combinatorial structure of choosing how many complete blocks occur, corresponding to binomial coefficients in $a$ and $b$.
The first part contributes the reduced Gaussian coefficient
$$ \binom{r}{s}_q, $$
since only the remainder classes $1,\ldots,r$ and $1,\ldots,s$ survive modulo $m$.
The second part counts how many full blocks of size $m$ are selected among $a$ blocks for $n$ and $b$ blocks for $k$, giving the ordinary binomial coefficient
$$ \binom{a}{b}=\binom{\lfloor n/m \rfloor}{\lfloor k/m \rfloor}. $$
Multiplicativity follows from independence of block choices and residue-class contributions, yielding
$$ \binom{n}{k}_q = \binom{\lfloor n/m \rfloor}{\lfloor k/m \rfloor} \binom{n \bmod m}{k \bmod m}_q. $$
Thus,
$$ \boxed{\binom{n}{k}_q = \binom{\lfloor n/m \rfloor}{\lfloor k/m \rfloor} \binom{n \bmod m}{k \bmod m}_q }. $$
This completes the proof. ∎