Making any integer with four 2s (2025)
- ID
- 44314
- Status
- summarized
- Published
- 08 Nov 2026, 6:38 AM
- Fetched
- 09 Nov 2026, 1:32 AM
- Provider
- Hacker News
- Category
- dev-community
- Original URL
- https://eli.thegreenplace.net/2025/making-any-integer-with-four-2s/
- Source URL
- https://hnrss.org/best
Summary
- Score
- 3.0
- Created
- 09 Nov 2026, 1:32 AM
- Tags
- Audience
- developers
What happened
Eli Bendersky walks through the classic 'four 2s' puzzle: simple expressions for 1–6, factorial/exponent tricks for 18, 28, 256, and 65536, and Dirac's general solution using nested square roots plus base-2 logarithms to produce any integer n. Dirac's formula uses three 2s, so the post patches it to exactly four by replacing a 2 with sqrt(2+2); the Hacker News thread has 180 points and 47 comments.
Why it matters
There is no direct tooling, policy, or startup decision here; it is a math puzzle with a clever constraint loophole. The only practical takeaway is a discussion prompt about spec-gaming: replacing one 2 with sqrt(2+2) keeps the letter of 'four 2s' while changing the puzzle, much like loopholes in API or product specs.
Discussion angle
Use the Dirac solution as a 5-minute live example: when does a clever substitution count as solving the constraint versus cheating? Compare it to how builders exploit ambiguous specs in APIs, pricing rules, or hackathon requirements.