diff options
author | Marvin Borner | 2022-10-29 22:14:13 +0200 |
---|---|---|
committer | Marvin Borner | 2022-10-29 22:14:13 +0200 |
commit | b1e8ffead806a10c8d6ac6912103dc6655d4d523 (patch) | |
tree | 2568b3fc5cdeded27e7f7330fbdf0ca5492c9f10 /research/root.py | |
parent | af1e28db0602c229f4b85d117075f964a196d33a (diff) |
huh
Diffstat (limited to 'research/root.py')
-rw-r--r-- | research/root.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/research/root.py b/research/root.py new file mode 100644 index 0000000..e0ef85f --- /dev/null +++ b/research/root.py @@ -0,0 +1,36 @@ +import math + +def compress(): + num = 25390283502835092850912835091098172509218753091220958203958230958230598230598203958098098098 + numlen = len(bin(num)) + print(f"prev: {numlen}") + + com = "" + key = "" + + i = 0 + p_total = math.inf + while True: + print("---") + s_d = s_n = s_k = math.inf + for n in range(255, 1, -1): + for k in range(255, 1, -1): + r = n ** k + d = abs(num - r) + if d < s_d: + s_d = d + s_n = n + s_k = k + # key += "{:08b}{:08b}".format(s_n, s_k) + key += "00000" + total = len(bin(s_d)) + len(key) + print(s_d, s_n, s_k) + print(f"total: {total}") + if total > p_total: + com = s_d + break + p_total = total + num = s_d + i += 1 + + print(f"iterations: {i}, prev: {numlen}, reduction by: {total / numlen}") |