The goal of the four fours puzzle is to represent each natural number using four copies of the digit $4$ and common mathematical symbols.

For example, $165=\left(\sqrt{4} + \sqrt{\sqrt{{\sqrt{4^{4!}}}}}\right) \div .4$.

If we remove the restriction on the number of fours, let $f(N)$ be the number of fours required to be able to represent all positive integers no greater than $N$. What is the asymptotic behaviour of $f(N)$? Can it be shown that $f(N) \sim r \log N$ for some $r$?

To be specific, let’s restrict the operations to the following:

  • addition: $x+y$
  • subtraction: $x-y$
  • multiplication: $x\times y$
  • division: $x\div y$
  • exponentiation: $y^x$
  • roots: $\sqrt[x]{y}$
  • square root: $\sqrt{x}$
  • factorial $n!$
  • decimal point: $.4$
  • recurring decimal: $. \overline 4$

It is easy to see that $f(N)$ is $O(\log N)$. For example, with four fours, numbers up to $102$ can be represented (see here for a tool for generating solutions), so, since $96 = 4\times4!$, we can use $6k-2$ fours in the form $(\dots((a_1\times 96+a_2)\times 96+a_3)\dots)\times96+a_k$ to represent every number up to $96^k$.

On the other hand, we can try to count the number of distinct expressions that can be made with $k$ fours. For example, if we (arbitrarily) permit factorial only to be applied to the digit $4$, and allow no more than two successive applications of the square root operation, we get $\frac{216^k}{18}C_{k-1}$ distinct expressions where $C_k$ is the $k$th Catalan number. (Of course, many of these expressions won’t represent a positive integer, many different expressions will represent the same number, and the positive integers generated won’t consist of a contiguous range from $1$ to some $N$.)

Using Stirling’s formula, for large $k$, this is approximately $\frac{864^k}{72k\sqrt{\pi k}}$. So for $f(N)$ to grow slower than $r\log N$, we’d need to remove the restrictions on the use of unary operations. (It is well-known that the use of logs enables any number to be represented with only four fours.)

Can this approach be extended to show that $f(N)$ is $\Omega(\log N)$? Or does unrestricted use of factorial and square roots mean that $f(N)$ is actually $o(\log N)$? Is the answer different if the use of $x\%$ (percentages) is also permitted?

  • 708
  • 7
  • 15
David Bevan
  • 5,812
  • 2
  • 16
  • 31
  • 5
    One more variant might include allowing concatenation (e.g. using $44$ or $444$). – J. M. ain't a mathematician Dec 23 '11 at 18:12
  • 1
    Why did you use \cdot for the decimal point? It puts dots over your numbers ; it's just plain weird. You should just put a single dot, like this ".". – Patrick Da Silva Dec 23 '11 at 18:19
  • 3
    @Patrick, I think the dots over the digits indicate repeating decimals. – Gerry Myerson Dec 23 '11 at 18:21
  • 14
    @PatrickDaSilva, I’ve used \cdot for the decimal point because a central dot is the convention in the U.K. for writing decimals (e.g. $3\!\cdot\!\! 14159$, not $3.14159$). A dot above a digit is created using \dot and is for recurring decimals (e.g. $\frac{1}{3}=0\!\cdot\!\!\dot 3$). I know conventions in other countries differ (e.g. the use of commas for decimal points in some mainland European countries). – David Bevan Dec 23 '11 at 18:26
  • 1
    @David : Sorry then, it's just that it confused me at first since I've never seen dots above things except for derivatives wrt time in physics. Thanks for clarifying. – Patrick Da Silva Dec 23 '11 at 18:34
  • 64
    By the way, if you allow logarithms, you don't even need four fours: actually three fours are enough to represent any positive integer like $ \log\bigl(\log 4/\log(\surd\surd\dots\surd4)\bigr)/\log 4 $. – b_jonas Mar 04 '12 at 12:02
  • 3
    This seems to be related to the concept "integer complexity". For example, see the recent paper by Harry Altman and Joshua Zelinsky, "Numbers With Integer Complexity Close to the Lower Bound" in [INTEGERS: The Electronic Journal of Combinatorial Number Theory](http://integers-ejcnt.org/vol12a.html). – David Bevan Oct 19 '12 at 08:02
  • 6
    To my knowledge this problem is open, and difficult, even for the case of 1s instead of 4s, and allowing only addition and multiplication. – user7530 Dec 24 '12 at 22:49
  • 1
    I wonder if it can be proved that one $4$ is sufficient to represent all positive integers if a floor function is also allowed? – Dan Brumleve Jan 06 '13 at 07:11
  • 6
    I'd prefer to remove the decimal and repeated-decimal operations. A "pure" representation of $N$ by fours shouldn't rely on the accident of the numerical base. – Blue Jan 06 '13 at 10:02
  • 2
    I can see the simplicity of the problem as posed in @DavidBevan link "Numbers With Integer Complexity Close to the Lower Bound", but with increasing the number of operations allowed the problem becomes rather arbitrary. Can someone explain the significance of the problem? – Maesumi Jan 12 '13 at 16:54
  • 1
    You should make the second half of your question an answer. [You *are* allowed to answer your own questions.](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/) – Joe Z. Feb 15 '13 at 17:01
  • 2
    Let's see which method is [Fourier](http://www.neatorama.com/2013/02/03/Higher-Math/). – JavaMan Feb 26 '13 at 05:00
  • @ZsbánAmbrus Can you please explain? – Departed May 19 '16 at 10:36
  • Note that using [`floor` (or `ceiling`) also enables any integer to be represented with just one four](https://math.stackexchange.com/questions/48633/using-floor-ceiling-square-root-and-factorial-functions-to-get-integers), and using [`sec(atan())` also enables any integer to be represented with just one four](http://paulbourke.net/fun/4444/jim_millar.html). @DanBrumleve – Cœur Sep 30 '18 at 20:06

4 Answers4


I'm one of the authors of the paper referenced by David Bevan in his comment. The four-fours was one inspiration for that problem, although others have thought about it also. The specific version of the problem there looks at the minimum number of $1$s needed to represent $n$ where one is allowed only addition and multiplication but any number of parentheses. Call this $g(n)$. For example, $g(6) \le 5$, since $6=(1+1)(1+1+1)$, and it isn't hard to show that $g(6)=5$. Even in this limited version of the problem, the question is generally difficult even to get asymptotics.

In some sense most natural questions of asymptotic growth are somewhat contained in this question, since one can write any given $k$ as $1+1+1...+1$ $k$ times, and $1=k/k$. Thus starting with some $k$ other than $1$ (such as $k=4$), the asymptotics stay bounded within a constant factor, assuming that addition and division are allowed.

However, actually calculating this sort of thing for any set of operations is generally difficult. In the case of integer complexity one has a straightforward way of doing so, since if one calculates $g(i)$ for all $i < n$, calculating $g(n)$ is then doable. This doesn't apply when one has other operations generally, with division and substraction already making an algorithm difficult. In this case, one can make such an algorithm but exactly how to do so is more subtle. In fact, as long as one is restricted to binary operations this is doable (proof sketch: do what you did to look at all distinct expressions).

Adding in non-binary operations makes everything even tougher. Adding in square roots won't make things that much harder, nor will adding factorial by itself. The pair of them together makes calculating specific values much more difficult. My guess would be that even with factorial, square root and the four binary operations there are numbers which require arbitrarily large numbers of $1$s, but I also suspect that this would be extremely difficult to prove. Note that this is already substantially weaker than what you are asking- whether the order of growth is of $\log n$. Here though square roots probably don't alter things at all; in order for it to matter one needs to have a lot numbers of the form n^2^k with surprisingly low complexity. This seems unlikely.

  • 10,379
  • 2
  • 7
  • 34
  • 1,539
  • 14
  • 14
  • The series with $1$'s is http://oeis.org/A005245 I didn't find any asymptotics there or at the easier linked http://oeis.org/A061373 but that one shows that the question is $O(\log N)$ as here for m=2^p3^q, a(m)=2p+3q – Ross Millikan Feb 26 '13 at 03:09
  • For the case of just + and *, the growth is known to be of O(log n) as the correct level. This and related details are discussed in the paper that Bevan referenced. Whether it is asymptotic to c log n for some constant c is open. – JoshuaZ Feb 26 '13 at 03:18
  • @user7530 Er, sorry, when I wrote f(n) I meant to define g(n). I had written it with f(n), then realized that using the same letter as the OP wasn't a good idea. I tried to go and make them all consistent but missed a few. Should be ok now. – JoshuaZ Feb 26 '13 at 04:04

You can get $103$ with five $4$s as $$\frac {\sqrt{\sqrt{\sqrt{4^{4!}}}}+4+\sqrt{.\overline4}}{\sqrt{.\overline4}}=103$$

For four $4$s, we have $\dfrac {44}{.\overline 4}+4=103$.

In fact, $113$ is the first number I can't get with four $4$s.

  • 204,278
  • 154
  • 264
  • 488
Mark Stephenson
  • 151
  • 1
  • 5
  • In reply to not knowing how to get the math notation: You can search for LaTeX tutorials and get most of the notation right there; it also doesn't hurt to click on "edit" in other people's posts just to see how they are doing it (you don't actually have to edit anything). – Dennis Meng Oct 20 '13 at 03:25
  • (And welcome to the site!) – Dennis Meng Oct 20 '13 at 03:26
  • Thanks! Incidentally, my example actually needs five 4s, but I know I've done it with four. – Mark Stephenson Oct 20 '13 at 23:42
  • 103 = 44 / .4. + 4 – David Bevan Oct 21 '13 at 09:59
  • I took up the Four 4's challenge ages ago... I seem to remember an answer for 113... $$\frac{4}{4\%}+\sqrt{\frac{4}{.\overline{4}}}$$ Taking advantage of the fact that 4% = 0.04 – Eliseo D'Annunzio Jan 09 '14 at 02:08
  • 1
    Ah, mea culpa, most results of https://www.cut-the-knot.org/arithmetic/funny/4_4.shtml are not applicable because it often uses the `floor` function. But they give 114 = 44/.4 + 4. Sadly, @Eliseod'Annunzio solution for 113 isn't applicable because `%` isn't explicitely allowed as well. – Cœur Sep 30 '18 at 20:18
  • 1
    The % formula gives 103 not 113. – Mark Stephenson Dec 22 '18 at 20:13

Go here to look at a YouTube video discussing the matter. It proves that for all $n\in\mathbb{Z}^+$,

$$\log_{\frac 12}(\log_4\sqrt [n]{4}) = n.$$

But notice that $\dfrac 12 = \dfrac 24 = \dfrac{\sqrt{4}}{{4}}$ so...

Edit: By $n^\text{th}$ root, I mean $n$ square roots. So for example, $\sqrt [2] {4} = \sqrt{\sqrt{4}}$ (because it is simple to write it this way).

  • 8,330
  • 2
  • 23
  • 42
Mr Pie
  • 9,157
  • 3
  • 21
  • 58
  • 3
    It was already aknowledge in the question itself that `log` was enabling any number to be represented with only four fours. – Cœur Sep 30 '18 at 20:28
  • @Cœur where, exactly? Is that expressed in the big-$O$ notation? I ain't familiar with that. – Mr Pie Sep 30 '18 at 20:46
  • 2
    Last sentence before the final quote: "(It is [well-known](http://en.wikipedia.org/wiki/Four_fours#Rules) that the use of logs enables _any_ number to be represented with only _four_ fours.)" – Cœur Sep 30 '18 at 20:56

It can't be $o(\log N)$ for any finite set of binary operations. For a set of operations of size $k$, you can only have of order $k^N$ legal strings, so you can't represent more numbers than that.

Ross Millikan
  • 362,355
  • 27
  • 241
  • 432
  • 7
    Not all of the operations are binary. For example, $$4!!!!\cdots !!!$$ for any number of factorials, can be written with one four – Zubin Mukerjee Jan 11 '15 at 16:50