Created
May 6, 2020 18:07
-
-
Save reloadedd/e3c19cd6b42d0088f4549704d25fef25 to your computer and use it in GitHub Desktop.
Revisions
-
reloadedd created this gist
May 6, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ #!/usr/bin/env python3 import sys def solve_equation(a, m, totient): k = 1 result = a ** k % m while result != 1 and k <= totient: k += 1 result = a ** k % m if k != totient: return 0 # print(f'\t => ordinul lui {a} modulo {m} = {k}') return totient def main(): if len(sys.argv) != 4: print(f'Usage: {sys.argv[0]} m totient totient_de_totient') exit(0) try: m = int(sys.argv[1]) except ValueError: print(f'Boss, de cand "{sys.argv[1]}"" e numar la tine?') exit(0) try: totient = int(sys.argv[2]) except ValueError: print(f'Boss, de cand "{sys.argv[2]}" e numar la tine?') exit(0) try: totient2 = int(sys.argv[3]) except ValueError: print(f'Boss, de cand "{sys.argv[3]}" e numar la tine?') exit(0) a = 1 k = 0 radacini = [] while k != totient2: if solve_equation(a, m, totient) != 0: print(f'\t => ordinul lui {a} modulo {m} = {totient}') k += 1 radacini.append(a) a += 1 print(f'Radacinile primitive modulo {m}, care sunt in numar de {totient2}, sunt:\n{radacini}') if __name__ == '__main__': main()