powertable[p_]:=Map[PowerMod[First[#],Last[#],p]&,Outer[List,Range[0,p-1],Range[1,p]],{2}]//
Prepend[#,Map[(a^#)&,Range[1,p]]]&//
TableForm[#,TableSpacing->Map[1&,Range[p]]]&
a | ||||||
0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 | 1 | 1 | 1 |
2 | 4 | 1 | 2 | 4 | 1 | 2 |
3 | 2 | 6 | 4 | 5 | 1 | 3 |
4 | 2 | 1 | 4 | 2 | 1 | 4 |
5 | 4 | 6 | 2 | 3 | 1 | 5 |
6 | 1 | 6 | 1 | 6 | 1 | 6 |