{"article":{"slug":"making-any-integer-with-four-2s","title":"Making any integer with four 2s","subtitle":null,"summary":"Eli Bendersky revisits the classic puzzle of building any natural number from exactly four 2s, from schoolroom arithmetic to factorials and the Gamma function, and walks through Paul Dirac's general solution using nested square roots and base-2 logarithms.","content_type":"blog_post","language":"en","canonical_url":"https://eli.thegreenplace.net/2025/making-any-integer-with-four-2s/","author":{"name":"Eli Bendersky","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"Eli Bendersky's website","url":"https://eli.thegreenplace.net/","listing_slug":null,"listing":null},"topics":[{"name":"math","slug":"math","url":"https://listedarticles.com/topics/math"},{"name":"puzzles","slug":"puzzles","url":"https://listedarticles.com/topics/puzzles"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":380,"reading_minutes":2,"published_at":"2025-02-22T00:00:00.000Z","added_at":"2026-11-08T05:16:40.112Z","updated_at":"2026-11-08T05:16:40.112Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/making-any-integer-with-four-2s","markdown_url":"https://listedarticles.com/articles/making-any-integer-with-four-2s.md","example":false,"citation":"Eli Bendersky, Eli Bendersky's website. \"Making any integer with four 2s.\" 22 Feb 2025. https://eli.thegreenplace.net/2025/making-any-integer-with-four-2s/ (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://eli.thegreenplace.net/2025/making-any-integer-with-four-2s/"},"body_markdown":"There's a cute math puzzle that can be interesting to folks on very different levels:\n\nGiven exactly four instances of the digit 2 and some target natural number,\nuse any mathematical operations to generate the target number with these 2s,\nusing no other digits.\n\nSome examples can be done by elementary school kids:\n\n![equation](https://eli.thegreenplace.net/images/math/32bde1d69161bfafd9d82a90e7cb6780fad170bd.svg)\n\nIn middle school, kids learn about exponents, factorials, etc. which expands the range considerably:\n\n![equation](https://eli.thegreenplace.net/images/math/d94f887fc9eaa65fa8f9b4f2d3e16b616c955bc3.svg)\n\nThen come the tricks; for example, the number 22 (twenty two) can be seen as a valid use of two 2s, and so on; so we can have:\n\n![equation](https://eli.thegreenplace.net/images/math/190e4202199c02f8e19dbcaf5df17a51128c266d.svg)\n\nGetting to 7 is notoriously difficult, but if you allow even more mathematical\ntools like the [Gamma function](https://en.wikipedia.org/wiki/Gamma_function),\nit becomes easy:\n\n![equation](https://eli.thegreenplace.net/images/math/6545e96cb2002506e8325398464fd9fbcea139b2.svg)\n\nThe more math skill people have, the more numbers they can make. See\n[this thread](https://math.stackexchange.com/questions/1034122/get-the-numbers-from-0-30-by-using-the-number-2-four-times)\nfor some fun concoctions using integrals, repeating fractions and combinatorial\noperators. One of my favorite examples involves complex numbers:\n\n![equation](https://eli.thegreenplace.net/images/math/e39bde378ab9e0e6cb10056b362f7577d71b01a5.svg)\n\nSo the fun doesn't end even after one graduates from university! In fact, this\nseems to have been a favorite pastime for mathematicians in the 1920s. Until\n[Paul Dirac](https://en.wikipedia.org/wiki/Paul_Dirac) ruined it for everyone\nby finding a general solution for every number.\n\nIt's all about nested square roots:\n\n![equation](https://eli.thegreenplace.net/images/math/e835771e322bfabb4c2b534bb3e482a0ab16f572.svg)\n\nIf the square root is applied *n* times:\n\n![equation](https://eli.thegreenplace.net/images/math/8a5dfa276462eac03469c8947905f9ed3ff078cf.svg)\n\nAll that's left now is some base-2 logarithms:\n\n![equation](https://eli.thegreenplace.net/images/math/e2702fe582b68043bda67bc86cbbe5568fcba690.svg)\n\nAnd another:\n\n![equation](https://eli.thegreenplace.net/images/math/d4ea49614466747aa6c8dc8b9d8d32b098bccc36.svg)\n\nThis leads to the general formula:\n\n![equation](https://eli.thegreenplace.net/images/math/2cf1c9369d2fb05dc5f272f6800b6ce4aec98010.svg)\n\nThere's just one small wrinkle: it uses *three* instances of the digit 2, not\nfour. This is easy to amend, however; since \n\n![equation](https://eli.thegreenplace.net/images/math/e44726a4b723409cfccff855966f13c3f4d77694.svg)\n\n, we can replace any single digit with that and get exactly four:\n![equation](https://eli.thegreenplace.net/images/math/648420602da4a3314d6c3d6d7aa0ccd0cf76e627.svg)\n\nOne may claim this is cheating, but it seems to be in line with the rules of\nthe puzzle! Note that the entity *n* doesn't actually appear anywhere - it's\njust a helper to count the number of repeated square roots. For example, another\nway to express 7 is:\n\n![equation](https://eli.thegreenplace.net/images/math/3eef0707ee8c500f9b7a6a55043ff3bd75573808.svg)\n\nThere are exactly four 2s, and this uses only reasonable, elemental math\noperations to do the calculation. It's clear that *any* number can be expressed\nthis way; the only challenge is properly drawing all those square roots!\n\n## Credits\n\nI've read about this story in Graham Farmelo's book\n*The Strangest Man: The Hidden Life of Paul Dirac, Quantum Genius*. I'm\nenjoying this book so far.","body_html":"<p>There&#39;s a cute math puzzle that can be interesting to folks on very different levels:</p>\n<p>Given exactly four instances of the digit 2 and some target natural number,\nuse any mathematical operations to generate the target number with these 2s,\nusing no other digits.</p>\n<p>Some examples can be done by elementary school kids:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/32bde1d69161bfafd9d82a90e7cb6780fad170bd.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>In middle school, kids learn about exponents, factorials, etc. which expands the range considerably:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/d94f887fc9eaa65fa8f9b4f2d3e16b616c955bc3.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>Then come the tricks; for example, the number 22 (twenty two) can be seen as a valid use of two 2s, and so on; so we can have:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/190e4202199c02f8e19dbcaf5df17a51128c266d.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>Getting to 7 is notoriously difficult, but if you allow even more mathematical\ntools like the <a href=\"https://en.wikipedia.org/wiki/Gamma_function\" rel=\"nofollow ugc noopener\">Gamma function</a>,\nit becomes easy:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/6545e96cb2002506e8325398464fd9fbcea139b2.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>The more math skill people have, the more numbers they can make. See\n<a href=\"https://math.stackexchange.com/questions/1034122/get-the-numbers-from-0-30-by-using-the-number-2-four-times\" rel=\"nofollow ugc noopener\">this thread</a>\nfor some fun concoctions using integrals, repeating fractions and combinatorial\noperators. One of my favorite examples involves complex numbers:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/e39bde378ab9e0e6cb10056b362f7577d71b01a5.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>So the fun doesn&#39;t end even after one graduates from university! In fact, this\nseems to have been a favorite pastime for mathematicians in the 1920s. Until\n<a href=\"https://en.wikipedia.org/wiki/Paul_Dirac\" rel=\"nofollow ugc noopener\">Paul Dirac</a> ruined it for everyone\nby finding a general solution for every number.</p>\n<p>It&#39;s all about nested square roots:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/e835771e322bfabb4c2b534bb3e482a0ab16f572.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>If the square root is applied *n* times:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/8a5dfa276462eac03469c8947905f9ed3ff078cf.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>All that&#39;s left now is some base-2 logarithms:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/e2702fe582b68043bda67bc86cbbe5568fcba690.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>And another:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/d4ea49614466747aa6c8dc8b9d8d32b098bccc36.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>This leads to the general formula:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/2cf1c9369d2fb05dc5f272f6800b6ce4aec98010.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>There&#39;s just one small wrinkle: it uses <em>three</em> instances of the digit 2, not\nfour. This is easy to amend, however; since </p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/e44726a4b723409cfccff855966f13c3f4d77694.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>, we can replace any single digit with that and get exactly four:\n<img src=\"https://eli.thegreenplace.net/images/math/648420602da4a3314d6c3d6d7aa0ccd0cf76e627.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></p>\n<p>One may claim this is cheating, but it seems to be in line with the rules of\nthe puzzle! Note that the entity *n* doesn&#39;t actually appear anywhere - it&#39;s\njust a helper to count the number of repeated square roots. For example, another\nway to express 7 is:</p>\n<figure><img src=\"https://eli.thegreenplace.net/images/math/3eef0707ee8c500f9b7a6a55043ff3bd75573808.svg\" alt=\"equation\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>There are exactly four 2s, and this uses only reasonable, elemental math\noperations to do the calculation. It&#39;s clear that <em>any</em> number can be expressed\nthis way; the only challenge is properly drawing all those square roots!</p>\n<h2 id=\"credits\">Credits</h2>\n<p>I&#39;ve read about this story in Graham Farmelo&#39;s book\n<em>The Strangest Man: The Hidden Life of Paul Dirac, Quantum Genius</em>. I&#39;m\nenjoying this book so far.</p>","headings":[{"level":2,"text":"Credits","id":"credits"}]}}