A few calculations in (SuperStar[(Subscript[ℤ, n])])

Math 202 Cryptography, October 28, 2016
T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

Calculate (a^i)mod 5 for all a∈(SuperStar[(Subscript[ℤ, 5])])

Let’s calculate (2^i) for 1 ≤ i ≤ 4. 
We can easily create this with a table.

Table[ Mod[2^i,5], {i,1,4}]

Or, we can do this for all a ∈ (SuperStar[(Subscript[ℤ, 5])])at once by using a double subscript
The powers of a will be in row a

Table[ Mod[a^i,5], {a,1,4},{i,1,4}] //TableForm

Thus, 2 and 3 are generators for (SuperStar[(Subscript[ℤ, 5])]) and 1 and 4 are not generators.

The MultiplicativeOrder[a,n] is also handy to find the multiplicative order of a in (SuperStar[(Subscript[ℤ, n])])

MultiplicativeOrder[2,5]

If  a is not in (SuperStar[(Subscript[ℤ, n])]), then MultiplicativeOrder[a,n] returns unevaluated

MultiplicativeOrder[2,6]

Calculate (a^i)mod 10 for all a∈(SuperStar[(Subscript[ℤ, 10])])

If the modulus isn’t prime, then we need to restrict to values relatively prime to 10
The following command will build the list

relprime=Select[Range[10],CoprimeQ[10,#]&]

We can use these values for a in the Table[ ] command, and notice we only need to calculate (a^i) for 1 ≤ i ≤ 4

Table[Mod[a^i,10], {a, relprime},{i,1,4}] //TableForm

Calculate (a^i)mod n for all a∈(SuperStar[(Subscript[ℤ, n])])

We can modify the commands so that we only need to specify n

n=18
Table[Mod[a^i,n], {a, Select[Range[n],CoprimeQ[n,#]&]},{i,1,EulerPhi[n]}] //TableForm