Making any integer with four 2s (2025)

172 points - yesterday at 10:38 PM

Source

Comments

hahajk today at 1:43 AM
i know everyone plays with their own rules, but from my perspective, a square root spends a 2 - it's not an operator like + or ! . there's an implicit "2" since you could also take the cube root or fourth root
Someone today at 1:07 PM
It’s true cheating, but if you assume the Peano axioms, you can write any integer with one zero without having to resort to complex functions such as √. For example (if I didn’t miscount the S-es or parentheses),

  S(S(S(S(S(S(S(0)))))))) = 7
adas0693 yesterday at 11:55 PM
there is a related problem (inspired by an interview questions from ITA software, a part of Google now) that asks to find the smallest positive integer that cannot be expressed using a digit K (in [2,9]) N times in an expression that involves the four basic arithmetic operations and the parentheses: +, -, *, /, (, and ).

to make the problem more interesting, the list of operations can be extended to include exponentiation and concatenation.

for example, using the four basic operations for N=4, and K in [2,9], we get:

7 cannot be computed in 4 2s; 11 cannot be computed in 4 3s; 10 cannot be computed in 4 4s; 8 cannot be computed in 4 5s; 9 cannot be computed in 4 6s; 4 cannot be computed in 4 7s; 5 cannot be computed in 4 8s; 4 cannot be computed in 4 9s;

gnabgib yesterday at 10:48 PM
Popular last year (368 points, 165 comments) https://news.ycombinator.com/item?id=43145753
bajard today at 7:48 AM
22 is cheating because 22 = 2*10+2 is arbitrary in base 10. If you write 22 in some base, you have to write the base, and that's an extra number.
teo_zero yesterday at 11:18 PM
Never understood why 7 is considered difficult...

7 = ⌈ 2.2² + 2 ⌉

allywilson today at 8:45 AM
I'll just drop this here (yes, it's 4 instead of 2 - they're twice as good): https://fourmula.awsum.info/
Arnt yesterday at 11:16 PM
Spoilsport.

And JFYI since December is near: https://rant.gulbrandsen.priv.no/hack/advent-calendar-for-ne...

deleted yesterday at 11:08 PM
shoo today at 8:06 AM
There's a direct trivial solution for any natural number using the successor function S(a) = a + 1 from Peano arithmetic.

Encode 0 as 2 + 2 - 2 - 2 then apply S a times to that 0.

Only depends upon natural numbers & Peano stuff, no need for construction of rationals, irrationals, logarithms, etc.