diff options
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}") |