Created
July 10, 2022 13:37
-
-
Save HirbodBehnam/b870749ae3b213c5128fc813bc539f45 to your computer and use it in GitHub Desktop.
Cycle finder for discrete logarithm problem
This file contains 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
def find_cyclic(p, g) -> int: | |
seen = set() | |
current = g | |
while True: | |
current *= g | |
current %= p | |
if current in seen: | |
print(sorted(seen)) | |
print(len(seen)) | |
return len(seen) | |
seen.add(current) | |
#find_cyclic(1971, 2) | |
#exit() | |
l = list() | |
for i in range(1501, 2000, 2): | |
l.append((i, find_cyclic(i, 2))) | |
l.sort(key=lambda x: x[1]) | |
print(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment