Making any integer with four 2s (2025) eli.thegreenplace.net · 177 points · 47 c...
HN Best 30 @best30
Making any integer with four 2s (2025) eli.thegreenplace.net · 177 points · 47 comments · HN thread
TL;DR Eli Bendersky's post describes the puzzle of writing any natural number using exactly four 2s and standard math operations. He recounts how Paul Dirac found a general method using nested square roots and base-2 logarithms, which can be amended to use exactly four 2s by replacing one digit with a helper parameter n that counts the nested roots. The HN thread argues mainly over whether a square root 'spends' a 2 and whether successor or rounding tricks break the spirit of the puzzle.
- The puzzle: build any target natural number using exactly four instances of the digit 2 and mathematical operations, with no other digits.
- Elementary tricks include concatenation (22 from two 2s) and exponents and factorials, which make small numbers easier; 7 is notoriously hard without special functions.
- Adding the Gamma function makes 7 easy, and higher-level tools such as integrals, repeating decimals and combinatorial operators give more concoctions.
- Dirac reportedly found a general formula in the 1920s using nested square roots applied n times, combined with base-2 logarithms.
- The general formula uses three 2s; one 2 can be replaced by a variable n that counts the nested roots, so it fits the four-2s rule.
- The author notes that n does not appear in the final expression, which he treats as a helper, and that any number can be expressed this way.
Discussion The thread mostly argues about rules rather than the mathematics. The largest strand asks whether a square root silently uses a 2, since the radical is an implicit square root, and whether that makes Dirac's construction cheating. Many commenters find the Peano successor function or the identity 2-2=0 a cleaner way to produce any integer, which some call spoiling the puzzle. Others point to a related IOCCC entry, a brute-force variant from an old interview problem, and a previous HN discussion. The mood is playful and nerdy, with some pedantic back-and-forth about multiplication and division.
- Square root spends a 2 and is not a free operator (some): Commenters argue that sqrt is the nth root with an implicit n=2, so using it consumes one of the four 2s. They compare it to the notation for other roots, such as the cube root written with a 3 index, and treat the implicit degree as a hidden digit.
- Square root is a single symbol, so it is allowed (many): Many argue that sqrt, log and ln are standard single operators, and that their hidden bases or degrees are conventions just like sin being in radians. They see the nested-root method as a legitimate use of the rules.
- Successor function or Peano arithmetic makes it trivial (many): Several commenters note that starting from 0 = 2+2-2-2 and applying the successor operator S repeatedly gives any natural number, with no roots or logs. They treat this as the real trivial solution and see Dirac's method as a more elaborate version of the same idea.
- Rounding or concatenation tricks are unfair (a few): Some dismiss 22 as a base-10 trick and find rounding such as ceil(2.2^2+2) a spoiler, while others counter that rounding and concatenation are valid mathematical operations in the spirit of the puzzle.
- Argument over whether multiplication is repeated addition (a few): A side debate starts from the claim that squaring is to multiplication as multiplication is to addition. Commenters push back that multiplication is scaling, that repeated addition only works for whole numbers, and that the definition extends to rationals and negatives.
Links from the comments