This link here shows that $\langle 3 \rangle$ is a generator for the given group by brute force method, that is trial and error. I was curious as to how to justify this using the theorem.
According to the Corollary, Generators of $\mathbb{Z}_n$:
An integer $k$ in $\mathbb{Z}_n$ is a generator of $\mathbb{Z}_n$ if and only if $\gcd(n, k) = 1$.
Using this we know that $5$ is a generator of the group since gcd($|\mathbb{Z}_7^*|, 5) = 1$. (here $|\mathbb{Z}_7^*| = 6$, i.e, order of the group)
Although gcd($|\mathbb{Z}_7^*|, 3) = 3$.
Where am I going wrong?
Regards,
I think you have confused the groups $$\langle \Bbb Z_n, +\rangle\tag1$$ and $$\langle \Bbb Z_n^\ast, \cdot\rangle\tag2$$
Often when we mention a group, we leave the group operation implicit, and often it isn't confusing. This time, it was confusing.
The theorem you cited about $\gcd(n,k)=1$ is about the additive groups of line $(1)$. But your post you linked to is finding a generator of one of the multiplicative group mentioned in line $(2)$.
As you observed, in this example, the group of interest, $\langle \Bbb Z_7^\ast, \cdot\rangle$, has six elements, not seven.
In fact $\langle \Bbb Z_7^\ast, \cdot\rangle$ and $\langle \Bbb Z_6, +\rangle$ happen to be isomorphic. But the isomorphism looks like this:
\begin{array}{c||cccccc} \langle \Bbb Z_6, +\rangle & 0 & \color{darkgreen}{1} & 2 & 3 & 4 & \color{purple}5 \\ \langle \Bbb Z_7^\ast, \cdot\rangle & 1 & \color{darkgreen}3 & 2 & 6 & 4 & \color{purple}5 \\ \end{array}
As the theorem says, elements $1$ and $5$ are generators of $\langle \Bbb Z_6, +\rangle$.
But the corresponding generators of $\langle \Bbb Z_7^\ast, \cdot\rangle$ are called $3$ and $5$.
(There is a second isomorphism. Can you find it?)
For $\langle \Bbb Z_6, +\rangle$, it's easy to find generators ($1$ is always a generator) and your theorem tells us how. But finding a generator of $\langle \Bbb Z_7^\ast, \cdot\rangle$ is not simple.