Making any integer with four 2s (2025) eli.thegreenplace.net · 41 points · 8 com...
HN Best 200 @best
Making any integer with four 2s (2025) eli.thegreenplace.net · 41 points · 8 comments · HN thread
TL;DR Eli Bendersky's post revisits the puzzle of writing any natural number using exactly four 2s and standard math operations. Starting from easy arithmetic, it climbs through factorials, the Gamma function and complex numbers, then reaches a general construction based on nested square roots and base-2 logarithms, credited to Paul Dirac, that needs only a slight modification to use exactly four 2s.
- Simple arithmetic with four 2s gets small numbers; the trick 22 counts as two 2s, which widens the range.
- Allowing exponents and factorials expands the reachable set, and the Gamma function makes 7 easy to reach.
- Mathematicians in the 1920s played this game; Dirac reportedly found a general solution covering every integer.
- The general formula uses nested square roots applied n times plus base-2 logarithms, and needs three 2s, which can be padded to four by replacing one digit with an expression equal to 2.
- The helper variable n only counts the nested roots and does not appear in the final expression, so the construction is considered within the rules.
- Bendersky credits Graham Farmelo's book The Strangest Man as the source of the story.
Discussion The thread is short and mostly playful. It starts with a pointer to an earlier Hacker News discussion of the same article and a suggestion that a brute-force search would settle things. Commenters then debate what counts as a legitimate solution, with one showing 7 can be made with exponentiation and rounding, and another replying that rounding ruins the fun. The mood is light and nerdy, with little disagreement beyond the rules.
- Puzzle is fun only with restricted operations (some): Commenters note that 7 is hard only when exponentiation and rounding are disallowed. With those tools it becomes trivial, so the difficulty depends entirely on the rules.
- Rounding or floor functions are cheating (some): One commenter argues that rounding spoils the intended challenge. The implied preference is for exact expressions without ceiling or floor operations.
- Brute-force search is a natural approach (a few): A commenter asks whether brute force is allowed, suggesting that a computer search is a straightforward way to explore the problem.
- Related problem with other digits and operations (a few): One commenter describes a known interview-style variant, asking for the smallest integer not expressible with N copies of a digit K, and lists results for four copies of each digit, including that 7 cannot be made from four 2s with the four basic operations.
Links from the comments
- Earlier HN discussion of this article, with 368 points and 165 comments.
- An advent calendar of nerdy puzzles suggested by a commenter.
#mathPuzzles #recreationalMath #integers #Dirac #numberTheory