<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith" -->

---
title: Making any integer with four 2s (2025) | daily.dev
description: This post explores a classic puzzle: make any target number using exactly four 2s and any math operations. Elementary tricks handle small numbers, while...
canonical: https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Making any integer with four 2s (2025) | daily.dev
og:description: This post explores a classic puzzle: make any target number using exactly four 2s and any math operations. Elementary tricks handle small numbers, while...
og:url: https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith
og:image: https://api.daily.dev/og/posts/vDHd5LIth.png
og:image:alt: Making any integer with four 2s (2025)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Making any integer with four 2s (2025)

**[Hacker News](https://daily.dev/sources/hn)** · 2 min read · 0 upvotes · 0 comments

## Summary

This post explores a classic puzzle: make any target number using exactly four 2s and any math operations. Elementary tricks handle small numbers, while exponents and factorials expand the range. Reaching 7 is notoriously hard, but the Gamma function makes it easy. Paul Dirac found a general solution using nested square roots and base-2 logarithms, which naturally uses three 2s, fixed by substituting log2(2) for one digit to get exactly four. It is clear that any number is expressible this way, limited only by how many nested square roots you're willing to draw.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://eli.thegreenplace.net/2025/making-any-integer-with-four-2s>

## Questions this post answers

### How did Paul Dirac solve the puzzle of making any number using only four 2s?

Dirac found a general formula using nested square roots and base-2 logarithms that can produce any natural number. The core method only needs three 2s, so a fourth 2 is inserted by replacing a digit with log base 2 of 2, which equals 1, keeping the value unchanged while satisfying the four-2s rule.

_daily.dev surfaces stories like this nested square root trick for developers who enjoy recreational math puzzles._

### Why is the number 7 considered hard to make using four 2s in math puzzles?

Reaching 7 is notoriously difficult with basic arithmetic operations like addition, multiplication, and factorials applied to four 2s. It becomes easy, however, once more advanced mathematical tools are allowed, such as the Gamma function, which extends factorial-like behavior to a broader set of inputs.

_developers curious about math puzzle solutions can keep discovering tricks like this via daily.dev._

## Community take

How the wider developer community reacted, aggregated from 3 discussions and 367 comments across hackernews (as of 2026-11-08).

**TL;DR:** Most discussion centers on whether the puzzle's rules are well-defined, with heavy debate over whether operations like square root, logarithm, gamma, and even the successor function implicitly 'hide' extra 2s or other digits, making the challenge trivial or arbitrary.

**Sentiment:** 20% positive · 55% mixed · 25% skeptical

**The case for**

- Some find the puzzle genuinely fun and enjoy finding elegant or surprising solutions without resorting to exotic functions.
- A few praise the Gamma function and Dirac's nested-square-root trick as creative, non-trivial constructions.

**The pushback**

- Many argue that allowing arbitrary or little-known functions (gamma, successor function, etc.) breaks the spirit of the game and makes any number trivially reachable.
- Several point out that square root and logarithm implicitly 'hide' a base-2 operand, so claiming they use zero 2s is inconsistent with disallowing other digit-hiding tricks.
- Commenters note the puzzle lacks a rigorous, agreed-upon set of allowed operations, making 'valid' solutions inherently subjective.
- Some find specific example choices in the article (like using sqrt(2+2) instead of sqrt(2*2)) oddly unintuitive or unnecessarily obfuscated.

**By community**

- hackernews (heated): Extensive, contentious back-and-forth over what counts as a 'legitimate' mathematical operation and whether functions like gamma, successor, or square root secretly smuggle in extra digits.

**Hottest debate:** Whether operations like square root, logarithm, and the gamma/successor functions implicitly consume an extra '2' (or other digit), which determines whether the puzzle's solutions are legitimate or trivial cheats.

**Open questions**

- What precise, agreed-upon set of allowed operations would make the puzzle well-defined and non-trivial?
- Is there a way to formally distinguish 'elementary' functions from arbitrary ones without being arbitrary itself?
- Could someone find a general solution restricted only to integer-to-integer functions (no roots or logs)?

**Highlights**

> I feel like the second you allow functions you've thrown the spirit of the game. Ex, the gamma function is (n-1)! So now you're making 7 with four twos and a one.  You've broken the spirit. If I can hide numbers in a function call... It's trivially easy to always succeed.
> — [horsawlarway on hackernews · 14 comments](https://news.ycombinator.com/item?id=43150481)

> My criteria are "no letters or digits from any language" (other than 2). So you can't use the log or S() or the gamma function, but you can use sqrt, because there is accepted symbology that does not require any atom of non-mathematical language to represent.
> — [saulpw on hackernews · 2 comments](https://news.ycombinator.com/item?id=43154910)

> But the square root has a hidden operand, 2. We don't write it because by convention the default root is 2, but that still feel like cheating to me.
> — [Biganon on hackernews · 1 comments](https://news.ycombinator.com/item?id=43152919)

> This is why people have brought up the successor function too: A + B, is, by definition B applications of Succ() on A:   A + B = Succ(Succ(Succ(...Succ(A)))) So using your own argument, we could say that using '+' is simply a convention on how we can write down the above — if we insist on spelling "conventional" things out, we must be able to use the underlying elementary function[].  Or isn't a factorial n! really n(n-1)...21, so all those numbers spelled out? The mathematical root probably first appeared as a square root and was later extended to support other exponents. But is there any fun in this?  As noted elsewhere, the game is in finding the rules, and a solution within those rules. []Since all the natural numbers other than 1 are defined using a Succ() functions, there's a trivial solution.  But if we only limit ourselves to this most elementary operation, we can't get a 1 because that's an axiom in itself ("There exists 1" or "There is a set of cardinality 1").
> — [necovek on hackernews · 1 comments](https://news.ycombinator.com/item?id=43155625)

> Alternatively, one can claim sqrt is a single symbol, and there are extensions requiring a digit. Log, ln, also have hidden bases, but they’re also valid symbols. Cos/sin may be in radians or degrees, both in common use, and no real place to denote it. One could even claim division is raising to the -1 power, thereby disqualifying it in exactly the same manner you disqualify sqrt. I’ve never seen sqrt with a 2 index; power -1 is seen quite often for division. Go figure….
> — [SideQuark on hackernews](https://news.ycombinator.com/item?id=50409898)

**Source threads**

- [hackernews](https://news.ycombinator.com/item?id=43145753) · 368 points · 322 comments
- [hackernews](https://news.ycombinator.com/item?id=43149883) · 238 points · 10 comments
- [hackernews](https://news.ycombinator.com/item?id=50408713) · 131 points · 35 comments

## Similar posts on daily.dev

- [How big are factorials?](https://daily.dev/posts/how-big-are-factorials--gttjlrfuh) · Eli Bendersky · 7 upvotes · 1 comments
- [Erdős Problem \#124](https://daily.dev/posts/erd-s-problem-124-5h47gaso9) · Hacker News · 1 upvotes · 0 comments
- [How did the Babylonians know √2 up to six digits?](https://daily.dev/posts/how-did-the-babylonians-know-2-up-to-six-digits--pymw94l8o) · The Palindrome · 0 upvotes · 0 comments

---

Tags: [#math](https://daily.dev/tags/math)

[View this post on daily.dev](https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Making any integer with four 2s (2025)","url":"https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith"},"datePublished":"2026-11-08T01:06:13.421Z","dateModified":"2026-11-08T08:52:06.331Z","description":"This post explores a classic puzzle: make any target number using exactly four 2s and any math operations. Elementary tricks handle small numbers, while...","image":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","thumbnailUrl":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","isAccessibleForFree":true,"articleSection":"Hacker News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Hacker News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/hn","url":"https://daily.dev/sources/hn"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"math","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Hacker News","item":"https://daily.dev/sources/hn"},{"@type":"ListItem","position":3,"name":"Making any integer with four 2s (2025)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/making-any-integer-with-four-2s-2025--vdhd5lith#faq","mainEntity":[{"@type":"Question","name":"How did Paul Dirac solve the puzzle of making any number using only four 2s?","acceptedAnswer":{"@type":"Answer","text":"Dirac found a general formula using nested square roots and base-2 logarithms that can produce any natural number. The core method only needs three 2s, so a fourth 2 is inserted by replacing a digit with log base 2 of 2, which equals 1, keeping the value unchanged while satisfying the four-2s rule. daily.dev surfaces stories like this nested square root trick for developers who enjoy recreational math puzzles."}},{"@type":"Question","name":"Why is the number 7 considered hard to make using four 2s in math puzzles?","acceptedAnswer":{"@type":"Answer","text":"Reaching 7 is notoriously difficult with basic arithmetic operations like addition, multiplication, and factorials applied to four 2s. It becomes easy, however, once more advanced mathematical tools are allowed, such as the Gamma function, which extends factorial-like behavior to a broader set of inputs. developers curious about math puzzle solutions can keep discovering tricks like this via daily.dev."}}]}
```

