Skip to content

Instantly share code, notes, and snippets.

@reloadedd
Created May 6, 2020 17:10
Show Gist options
  • Select an option

  • Save reloadedd/c13e18cd4912472ac8aa3609bc982afd to your computer and use it in GitHub Desktop.

Select an option

Save reloadedd/c13e18cd4912472ac8aa3609bc982afd to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
def solve_equation(a, m):
k = 1
result = a ** k % m
while result != 1:
k += 1
result = a ** k % m
print(f'{a} ^ {k} ≡ {result} mod {m}')
print(f'\t => ordinul lui {a} modulo {m} = {k}')
def main():
if len(sys.argv) != 3:
print(f'Usage: {sys.argv[0]} a m')
exit(0)
try:
a = int(sys.argv[1])
except ValueError:
print(f'Boss, de cand "{sys.argv[1]}"" e numar la tine?')
exit(0)
try:
m = int(sys.argv[2])
except ValueError:
print(f'Boss, de cand "{sys.argv[2]}" e numar la tine?')
exit(0)
solve_equation(a, m)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment