Prevent similar consecutive colours for a pie chart Background
Calculating colours for pie chart wedges. Consider:
$$
\begin{align}
d(n)&=\frac{\theta}{t}\times n\\
\end{align}
$$
Where:


*

*$\theta$ is the degrees in a circle (360)

*$t$ is the total number of wedges (can be odd), and $0 \leq t \leq \theta$

*$n$ is the wedge number, and a whole number

*$d(n)$ is the calculated hue assigned to a wedge


For $t=12$ and $n=\{1,2,3,...,t\}$, the calculation in LCH colour space produces:

Problem
Similar colours are adjacent, which is undesirable.
Colour Swap
Algorithmically, wedges can be swapped. When the wedge number, $n$, is even:
$$
\text{if}\, n \leq \frac{t}{2} \text{, then}\, n=n+\frac{t}{2} \text{; otherwise,}\, n=n-\frac{t}{2}
$$
This would work, but I'm wondering if there's a better way.
Question
What single calculation (using simple arithmetic, if possible) for $d(n)$ would prevent similar adjacent colours?
 A: Given $t$ colours and $n$ in $\{1,2,...,t\}$, then:
$$
\begin{align}
t_e&=t+\left(1-\left(t\,\%\,2\right)\right)\\
n_a&=\left[(n-\left(t\,\%\,2\right))\left\lfloor\frac{t}{2}\right\rfloor\,\%\,t_e\right]+\left(t\,\%\,2\right)\\
d(n_a)&=\frac{\theta}{t}\times n_a\\
\end{align}
$$
The floor ($\lfloor\,\rfloor$) and modulus ($\%$) functions are implemented most programming languages:
te = t + (1- (t mod 2))
((n-(t mod 2)) * floor(t / 2) mod te) + (t mod 2)

A: If $t$ is odd, then the obvious algorithm is to step around $t$ evenly spaced points on the colour chart by $\left\lfloor \frac {t-1}{2}\right\rfloor$ points each time, drawing the spikiest possible $t$-gram (the pentagram (13524), heptagram (147362), etc).
In general you can take the integer next below $\frac{t}{2}$ that is coprime to $t$, for a reasonably good solution. It isn't optimal for the special cases $t=4$, $t=6$ for which that integer is 1, when sequences $(1324)$ and $(142536)$ give fewer adjacent colour pairs. So I suppose there are larger $t$ where you can also do better, though I don't immediately see the pattern.
