Can we have $x^3 \equiv 1 \pmod n$? For $n \geq 5$ can we have $x^3\equiv 1 \pmod n$. And if so for what $n$?
I was thinking that we need $x^2 \equiv x^{-1}$ but I cant see when thats possible if possible.
Regards.
 A: of course we can, take $\bmod 3^k$, the multiplicative group $\bmod 3^k$ is isomorphic to $\mathbb Z_{2\cdot3^{k-1}}$, since cyclic groups have exactly one subgroup of each order that divides the order of the group there are exactly $2$ elements of order $3$.
A: I will assume you are asking following question:

For what integer $n \ge 5$, we can find an integer $x$ such that
  $$x \not\equiv 1 \pmod n \quad\text{ and }\quad x^3 \equiv 1 \pmod n\tag{*1}$$

The answer is 

Such a $x$ exists if and only if $\;9 | n\;$ or $n$ contains a prime factor of the form $3k+1$.

It is too bad I cannot come up with a completely elementary proof. 
Following derivations need some knowledge of group theory.

If such a $x$ exists, then $\;x (x^2) = x^3 \equiv 1 \pmod n\;$ implies $x$ belongs
to $(\mathbb{Z}/n\mathbb{Z})^\times$, the 
multiplicative group of integers modulo $n$
consisting of congruence classes of integers relative prime to the modulus number $n$.
It is known that $(\mathbb{Z}/n\mathbb{Z})^\times$ contains $\varphi(n)$ elements where $\varphi(\cdot)$ is Euler's totient function.
For any $x \in (\mathbb{Z}/n\mathbb{Z})^\times$, the condition $(*1)$ is equivalent to
the question whether the order of $x$ is $3$ or not. If such a $x$ exists, then by a well known corollary of Lagrange's theorem,
$$3 = \text{order}(x) \;|\; \# (\mathbb{Z}/n\mathbb{Z})^\times = \varphi(n)$$
On the other direction, if $3 | \varphi(n)$, then by 
Cauchy's theorem,
the finite group $(\mathbb{Z}/n\mathbb{Z})^\times$ contains an element of order $3$.
Combine these, we find such a $x$ exists if and only if $3 | \varphi(n)$.
Let $n = p_1^{e_1} p_2^{e_2} \cdots p_r^{e_r}$ be the factorization of $n$ into its prime factors. By Chinese remainder theorem,
$$
\mathbb{Z}/n\mathbb{Z} \simeq 
\mathbb{Z}/p_1^{e_1}\mathbb{Z} \times
\mathbb{Z}/p_2^{e_2}\mathbb{Z} \times \cdots
\mathbb{Z}/p_r^{e_r}\mathbb{Z} \\
\implies
(\mathbb{Z}/n\mathbb{Z})^\times \simeq 
(\mathbb{Z}/p_1^{e_1}\mathbb{Z})^\times \times
(\mathbb{Z}/p_2^{e_2}\mathbb{Z})^\times \times \cdots
(\mathbb{Z}/p_r^{e_r}\mathbb{Z})^\times
\tag{*2}
$$
This leads to
$$\varphi(n) = \varphi(p_1^{e_1}) \varphi(p_2^{e_2}) \cdots \varphi(p_r^{e_r})
= (p_1-1)p_1^{e_1-1} \cdot (p_2-1)p_2^{e_2-1} \cdots (p_r-1)p_r^{e_r-1}$$
From this, it is easy to see there are two ways for $\;3 | \varphi(n)\;$, namely:


*

*$3$ appear as one of the $p_i$ and the corresponding exponent $e_i > 1$.

*$3$ is a factor of one of $p_i - 1$.


i.e. $(*1)$ has a solution if and only if $\;9|n\;$ or $n$ contains a prime factor of the form $3k+1$. 
We know for odd prime $p$, groups of the form $( \mathbb{Z}/p^e \mathbb{Z} )^\times$ is a cyclic group. 
A cyclic group of order $m$ contains a cyclic subgroup of order $3$ if and only if $3 | m$. 
If exists, the cyclic subgroup is unique.
Since $(*2)$ tell us $(\mathbb{Z}/n\mathbb{Z})^\times$ is a direct product, we find:

The number of solutions for $(*1)$ is equal to $3^{s+t} - 1$ where 
  
  
*
  
*$s = 1$ when $\;9|n\;$ and $0$ otherwise.
  
*$t$ is the number of prime factors of $n$ of the form $3k+1$.
  

