Flipping k adjacent coins from n coins laid on a circle to make them all head-up Think of $n(\geq3)$ coins laid on a circle, each showing head-up or tail-up. The goal is to make every coin head-up by flipping $k$ adjacent coins several times.
What is the necessary and sufficient condition of $n$ and $k$ for achieving this goal from any starting state?
For example, I show an example below, where $n=4, k=3$:

('O' means head)
I figured out two conditions by invariant: 


*

*$k$ should be odd

*$k \nmid n$
But I'm stuck showing whether this is an if and only if condition.
 A: It is about the question whether the set of $n$ vectors
\begin{align}
\{x\in \mathbb{F}_2^n: x \text{ is a cyclic permutation of } (\underbrace{1,\ldots,1}_{k},0,\ldots,0)\}
\end{align}
is a basis of $\mathbb{F}_2^n$ or not. Therefore, it is enough to check whether the circulant matrix with first column $(\underbrace{1,\ldots,1}_{k},0,\ldots,0)$ is singular or not.
Assume that this circulant matrix is invertible. Then,
\begin{align}
\text{gcd}(1+x+\ldots+x^{k-1},x^n-1) =1
\end{align}
(See Corollary 10 in ON CIRCULANT MATRICES, In this link, circulant matrix over $\mathbb C$ is described but it also holds for $\mathbb{F}_2$ since the inverse of circulant matrix on the finite field is again circulant by Cramer's rule).
Since
\begin{align}
\text{gcd}(1+x+\ldots+x^{k-1},x^n-1) &=\text{gcd}(1+x+\ldots+x^{k-1},1+x+\ldots+x^{n-1}) \\&= 1+x+\ldots+x^{\text{gcd}(n,k)-1}
\end{align}
for odd $k$,
and
\begin{align}
(1+x)|\text{gcd}(1+x+\ldots+x^{k-1},x^n-1)
\end{align}
for even $k$, the if and only if conditions are


*

*$k$ is odd,

*$n,k$ are coprime.

