CINXE.COM

Eli Bendersky's website

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml"> <head> <title>Eli Bendersky's website</title> <!-- Using the latest rendering mode for IE --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://eli.thegreenplace.net/favicon.ico" rel="icon"> <!-- Bootstrap --> <link rel="stylesheet" href="https://eli.thegreenplace.net/theme/css/bootstrap.min.css" type="text/css"/> <link href="https://eli.thegreenplace.net/theme/css/font-awesome.min.css" rel="stylesheet"> <link href="https://eli.thegreenplace.net/theme/css/pygments/vs.css" rel="stylesheet"> <link rel="stylesheet" href="https://eli.thegreenplace.net/theme/css/style.css" type="text/css"/> <link href="https://eli.thegreenplace.net/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Eli Bendersky's website ATOM Feed"/> </head> <body> <div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a href="https://eli.thegreenplace.net/" class="navbar-brand"> <img src="https://eli.thegreenplace.net/images/logosmall.png" width="32" height="32"/> Eli Bendersky's website </a> </div> <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav navbar-right"> <li> <a href="https://eli.thegreenplace.net/pages/about"> <i class="fa fa-question"></i> <span class="icon-label">About</span> </a> </li> <li> <a href="https://eli.thegreenplace.net/pages/projects"> <i class="fa fa-github"></i> <span class="icon-label">Projects</span> </a> </li> <li> <a href="https://eli.thegreenplace.net/archives/all"> <i class="fa fa-th-list"></i> <span class="icon-label">Archives</span> </a> </li> </ul> </div> <!-- /.navbar-collapse --> </div> </div> <!-- /.navbar --> <div class="container"> <div class="row"> <article> <h1><a href="https://eli.thegreenplace.net/2025/making-any-integer-with-four-2s/">Making any integer with four 2s</a> </h1> <span class="published"> <i class="fa fa-calendar"></i> <time> February 22, 2025 at 14:53</time> </span> <br/><br/> <div class="entry-content"> <p>There's a cute math puzzle that can be interesting to folks on very different levels:</p> <blockquote> Given exactly four instances of the digit 2 and some target natural number, use any mathematical operations to generate the target number with these 2s, using no other digits.</blockquote> <p>Some examples can be done by elementary school kids:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/32bde1d69161bfafd9d82a90e7cb6780fad170bd.svg" style="height: 214px;" type="image/svg+xml">\[\begin{align*} 1&amp;=\frac{2+2}{2+2}\\ 2&amp;=\frac{2}{2}+\frac{2}{2}\\ 3&amp;=2\cdot2-\frac{2}{2}\\ 4&amp;=2+2+2-2\\ 5&amp;=2\cdot 2 +\frac{2}{2}\\ 6&amp;=2\cdot 2\cdot 2 - 2\\ \end{align*}\]</object> <p>In middle school, kids learn about exponents, factorials, etc. which expands the range considerably:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/d94f887fc9eaa65fa8f9b4f2d3e16b616c955bc3.svg" style="height: 109px;" type="image/svg+xml">\[\begin{align*} 18&amp;=2^{2^{2}}+2\\ 28&amp;=(2+2)!+2+2\\ 256&amp;=(2+2)^{2+2}\\ 65536&amp;=2^{2^{2^{2}}}\\ \end{align*}\]</object> <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> <object class="align-center" data="https://eli.thegreenplace.net/images/math/190e4202199c02f8e19dbcaf5df17a51128c266d.svg" style="height: 87px;" type="image/svg+xml">\[\begin{align*} 26&amp;=22+2+2\\ 11&amp;=\frac{22}{\sqrt{2+2}}\\ 444&amp;=222\cdot 2\\ \end{align*}\]</object> <p>Getting to 7 is notoriously difficult, but if you allow even more mathematical tools like the <a class="reference external" href="https://en.wikipedia.org/wiki/Gamma_function">Gamma function</a>, it becomes easy:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/6545e96cb2002506e8325398464fd9fbcea139b2.svg" style="height: 19px;" type="image/svg+xml">\[7&amp;=\Gamma(2)+2+2+2\]</object> <p>The more math skill people have, the more numbers they can make. See <a class="reference external" href="https://math.stackexchange.com/questions/1034122/get-the-numbers-from-0-30-by-using-the-number-2-four-times">this thread</a> for some fun concoctions using integrals, repeating fractions and combinatorial operators. One of my favorite examples involves complex numbers:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/e39bde378ab9e0e6cb10056b362f7577d71b01a5.svg" style="height: 22px;" type="image/svg+xml">\[12=|2+2\sqrt{-2}|^2\]</object> <p>So the fun doesn't end even after one graduates from university! In fact, this seems to have been a favorite pastime for mathematicians in the 1920s. Until <a class="reference external" href="https://en.wikipedia.org/wiki/Paul_Dirac">Paul Dirac</a> ruined it for everyone by finding a general solution for every number.</p> <p>It's all about nested square roots:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/e835771e322bfabb4c2b534bb3e482a0ab16f572.svg" style="height: 115px;" type="image/svg+xml">\[\begin{align*} \sqrt{2}=2^{\frac{1}{2}}=2^{2^{-1}}\\ \sqrt{\sqrt{2}}=2^{\frac{1}{4}}=2^{2^{-2}}\\ \sqrt{\sqrt{\sqrt{2}}}=2^{\frac{1}{8}}=2^{2^{-3}}\\ \end{align*}\]</object> <p>If the square root is applied <em>n</em> times:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/8a5dfa276462eac03469c8947905f9ed3ff078cf.svg" style="height: 43px;" type="image/svg+xml">\[\sqrt{\sqrt{\cdots n \cdots\sqrt{2}}}=2^{2^{(-n)}}\]</object> <p>All that's left now is some base-2 logarithms:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/e2702fe582b68043bda67bc86cbbe5568fcba690.svg" style="height: 24px;" type="image/svg+xml">\[log_{2}2^{2^{(-n)}}=2^{(-n)}\]</object> <p>And another:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/d4ea49614466747aa6c8dc8b9d8d32b098bccc36.svg" style="height: 25px;" type="image/svg+xml">\[log_{2}(log_{2}2^{2^{(-n)}})=-n\]</object> <p>This leads to the general formula:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/2cf1c9369d2fb05dc5f272f6800b6ce4aec98010.svg" style="height: 55px;" type="image/svg+xml">\[n = -log_{2}\left(log_{2}\left(\sqrt{\sqrt{\cdots n \cdots\sqrt{2}}}\right)\right)\]</object> <p>There's just one small wrinkle: it uses <em>three</em> instances of the digit 2, not four. This is easy to amend, however; since <object class="valign-m3" data="https://eli.thegreenplace.net/images/math/e44726a4b723409cfccff855966f13c3f4d77694.svg" style="height: 18px;" type="image/svg+xml">2=\sqrt{2+2}</object>, we can replace any single digit with that and get exactly four:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/648420602da4a3314d6c3d6d7aa0ccd0cf76e627.svg" style="height: 55px;" type="image/svg+xml">\[n = -log_{\sqrt{2+2}}\left(log_{2}\left(\sqrt{\sqrt{\cdots n \cdots\sqrt{2}}}\right)\right)\]</object> <p>One may claim this is cheating, but it seems to be in line with the rules of the puzzle! Note that the entity <em>n</em> doesn't actually appear anywhere - it's just a helper to count the number of repeated square roots. For example, another way to express 7 is:</p> <object class="align-center" data="https://eli.thegreenplace.net/images/math/3eef0707ee8c500f9b7a6a55043ff3bd75573808.svg" style="height: 117px;" type="image/svg+xml">\[7=-log_{\sqrt{2+2}}\left(log_{2}\left( \sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{2}}}}}}}\right)\right)\]</object> <p>There are exactly four 2s, and this uses only reasonable, elemental math operations to do the calculation. It's clear that <em>any</em> number can be expressed this way; the only challenge is properly drawing all those square roots!</p> <div class="section" id="credits"> <h2>Credits</h2> <p>I've read about this story in Graham Farmelo's book <em>The Strangest Man: The Hidden Life of Paul Dirac, Quantum Genius</em>. I'm enjoying this book so far.</p> </div> </div> </article> <hr class="style-eight"/> <h3>Recent posts</h3> <table class="archive-list"> <tr> <td style="padding-right: 10px">2025.02.18:</td> <td><a href='https://eli.thegreenplace.net/2025/benchmarking-utility-for-python/'>Benchmarking utility for Python</a></td> </tr> <tr> <td style="padding-right: 10px">2025.02.03:</td> <td><a href='https://eli.thegreenplace.net/2025/decorator-jits-python-as-a-dsl/'>Decorator JITs - Python as a DSL</a></td> </tr> <tr> <td style="padding-right: 10px">2025.01.13:</td> <td><a href='https://eli.thegreenplace.net/2025/reverse-mode-automatic-differentiation/'>Reverse mode Automatic Differentiation</a></td> </tr> <tr> <td style="padding-right: 10px">2024.12.31:</td> <td><a href='https://eli.thegreenplace.net/2024/summary-of-reading-october-december-2024/'>Summary of reading: October - December 2024</a></td> </tr> <tr> <td style="padding-right: 10px">2024.12.18:</td> <td><a href='https://eli.thegreenplace.net/2024/implementing-raft-part-5-exactly-once-delivery/'>Implementing Raft: Part 5 - Exactly-once delivery</a></td> </tr> <tr> <td style="padding-right: 10px">2024.11.22:</td> <td><a href='https://eli.thegreenplace.net/2024/gomlx-ml-in-go-without-python/'>GoMLX: ML in Go without Python</a></td> </tr> <tr> <td style="padding-right: 10px">2024.11.11:</td> <td><a href='https://eli.thegreenplace.net/2024/ml-in-go-with-a-python-sidecar/'>ML in Go with a Python sidecar</a></td> </tr> <tr> <td style="padding-right: 10px">2024.11.02:</td> <td><a href='https://eli.thegreenplace.net/2024/ranging-over-functions-in-go-123/'>Ranging over functions in Go 1.23</a></td> </tr> <tr> <td style="padding-right: 10px">2024.10.29:</td> <td><a href='https://eli.thegreenplace.net/2024/bloch-sphere/'>Bloch sphere</a></td> </tr> <tr> <td style="padding-right: 10px">2024.10.17:</td> <td><a href='https://eli.thegreenplace.net/2024/calculating-the-norm-of-a-complex-number/'>Calculating the norm of a complex number</a></td> </tr> </table> <br/> See <a href="https://eli.thegreenplace.net/archives/all">Archives</a> for a full list. </div> </div> <footer> <div class="container"> <hr> <div class="row"> <div class="col-xs-10"> &copy; 2003-2025 Eli Bendersky </div> <div class="col-xs-2"><p class="pull-right"><i class="fa fa-arrow-up"></i> <a href="#">Back to top</a></p></div> </div> </div> </footer> <script src="//code.jquery.com/jquery-2.2.4.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="https://eli.thegreenplace.net/theme/js/bootstrap.min.js"></script> <!-- Using goatcounter to count visitors. The count.js script is vendored in. --> <script data-goatcounter="https://stats.thegreenplace.net/count" async src="https://eli.thegreenplace.net/theme/js/count.js"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10