Find the invertible elements of $Z_6$, $Z_7$, and $Z_8$.
From the book: Solution By ‘trial and error’, the invertible elements are: $$Z_6 : 1, 5\\ Z_7 : 1, 2, 3, 4, 5, 6\\ Z_8 : 1, 3, 5, 7$$
I don't understand what is done with 'trial and error'.
An element $r$ in $Z_m$ is invertible if there is some $x$ in $Z_m$ such that $rx=1$.
$$Z_6={\{1,2,3,4,5}\}\\ 1\cdot 1=1\\ 5\cdot \frac{1}{5}=1$$
But $\frac{1}{5}$ is not in $Z_6$. Why is that invertible?
EDIT: Have i understood the math correct (based on the answer)?
If I test everything with $5$ from $Z_6$: $$5*1=5(mod6)\\ 5*2=4(mod6)\\ 5*3=3(mod6)\\ 5*4=2(mod6)\\ 5*5=1(mod6)$$
$5*5=1(mod6)$ gives the answer $=1$. Therefor $5$ from $Z_6$ is invertible.
$$3*1=3(mod6)\\ 3*2=0(mod6)\\ 3*3=3(mod6)\\ 3*4=0(mod6)\\ 3*5=3(mod6)$$
None give the answer $=1$. Therefor $3$ from $Z_6$ is not ivnertible.
Let $\varphi$ be the Euler phi function such that, for any $n \in \mathbb N$, we have $$\varphi(n)=|\{m\in \mathbb N:m<n\text{, gcd(m,n)=1}\}|.$$
In $\mathbb Z_n$ the number of invertible elements is given by $\varphi(n)$. In your case, $\mathbb Z_6$ has two invertible elements, infact $\varphi(6)=|\{1,5\}|=2$.
The inverse of $5$ in $\mathbb Z_6$ is $5$ because $5\cdot5=25=1+4\cdot6\equiv_6 1.$
Rmk: let $p\in \mathbb N$ be a prime number $\implies$ the cardinality of the set of invertible elements in $\mathbb Z_p$ is $p-1$ because $|U(\mathbb Z_p)|=\varphi(p)=p-1.$