Created
May 6, 2020 17:10
-
-
Save reloadedd/c13e18cd4912472ac8aa3609bc982afd 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
| #!/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