Syntax for Table[ ] and EulerPhi[ ]
Math 202 Cryptography
October 1, 2018

T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

Basic Examples of Table[ ]

Mathematica’s Help describes the syntax better than I can, so I’ll just give a few examples.

t1 = Table[i, {i,1,10}]
t1 //TableForm

n=13
t2=Table[ Mod[i^2, n], {i,1,n-1}]
t2 //TableForm

n=13
t3=Table[ {i,Mod[i^2, n]}, {i,1,n-1}]
t3 //TableForm

EulerPhi[n]

Not surprisingly, Mathematica has the Euler ϕ function built in

EulerPhi[6]

EulerPhi[35]

Combining the two

This will compute (a^(ϕ(p)))mod p for a=0, . . ., p-1

p=5
phi = EulerPhi[p]
Table[ {a, Mod[ a^phi, p]}, {a,1,p-1}] //TableForm