Created
May 4, 2017 11:51
-
-
Save tomato42/a3188e965a65a1c226ca7d1fe977d9a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
import getopt | |
import math | |
g = None | |
m = None | |
argv = sys.argv[1:] | |
opts, args = getopt.getopt(argv, "m:") | |
for opt, arg in opts: | |
if opt == '-m': | |
m = int(arg) | |
else: | |
raise Exception("Unrecognised option: {0}".format(opt)) | |
if args: | |
raise Exception("Not matching options: {0}".format(args)) | |
if m < 1: | |
raise Exception("Must specify -m, must be positive integer") | |
print("Groups modulo {0}".format(m)) | |
for g in range(m): | |
group_el = [] | |
for e in range(m+1): | |
val = pow(g, e, m) | |
if val in group_el: | |
break | |
group_el.append(val) | |
print('g: {0:>{width}}, len: {2:>{width}}, {1}'.format( | |
g, group_el, | |
len(group_el), | |
width=int(math.ceil(math.log10(m))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment