Four fours is a famous puzzle (made trivial with logarithms). For this puzzle, we take inspiration from Glen O's challenge from a few years back. The rules here are slightly different, but the goal is the same. Your goal is to approximate $\pi$ to the highest accuracy (per operation) as possible, using only four fours and the following operations:

  • The classic arithmetic operations: $+,-,\times,\div$
  • Exponentiation and log-base as binary operations: $\log_a b$ and $a^b$. You may only take logs of positive real numbers.
  • The root function as a binary operator $\sqrt[b]{a}$.
  • Unary operations: $(\cdot)!$ for integer arguments only (so you can't use $\frac12!$ to get $\sqrt{\pi}/2$), unary negation $-$, the square root $\sqrt{\cdot}$, and floor/ceiling for rounding down/up: $\lfloor\cdot\rfloor$ and $\lceil \cdot\rceil$.

Any other operations are not allowed, including double factorials and decimal points. In addition, you can do the following with no penalty:

  • Parentheses (for grouping purposes only, no binomial coefficients etc.)
  • Concatenation of 4's. That is, you can use 44 as a single number without costing an operation. You cannot concatenate things that are not fours, e.g. you can't concatenate $\sqrt{4}$ and $4!$ to get 224.
  • You do not have to use all four fours (e.g. msh210's answer of $\lfloor 4\rfloor$ is allowed).

Your score is equal to the number of digits of accuracy per operation used. That is, if you got the approximation $A$ by using $n$ operations, your score is $$ \frac{-\log_{10}|\pi - A|}{n} $$ To avoid division by 0, you must use at least one operation.

As an example, if you submit $\sqrt{(44 - 4!)/4} = \sqrt{5}\approx 2.24$, that has 4 operations, so your score would be:$$ \frac{-\log_{10} |\pi - \sqrt{5}|}4 \approx 0.01438... $$

  • 2
    $\begingroup$ It would be more appropriate to post this here, as the problem would probably get closed for 'lack of context' on Math SE. $\endgroup$ – Toby Mak May 5 '20 at 12:25
  • $\begingroup$ If anyone can get $\log_2 (\sqrt{8} + 6) \approx 3.1422$ in $4$ operations, you would get a score of approximately $0.812$. $\endgroup$ – Toby Mak May 5 '20 at 12:27
  • 1
    $\begingroup$ Are more than 4 fours allowed? $\endgroup$ – new QOpenGLWidget May 5 '20 at 13:55
  • $\begingroup$ @zixuan No, you can only use up to 4 fours. $\endgroup$ – Dark Malthorp May 5 '20 at 14:11
  • $\begingroup$ It would be very interesting to know how many fours and operations are needed for any given accuracy. $\endgroup$ – Anush May 24 '20 at 15:56

10 Answers 10


Three fours, five operations, score 1.0413

$$ \sqrt[4!]{4!}+\sqrt{4} \approx 3.141586 $$

Also five operations but too cute not to include, score 0.7539:

$$ \sqrt[4]{44\sqrt{\sqrt{4!}}} \approx 3.141423 $$

Four operations, score 0.7059:

$$ \sqrt4^\sqrt{\log_4{44}} \approx 3.143093 $$

The best three-operation expression has already been posted in another answer.

For completeness sake, two, score 0.4245:

$$ \left\lceil \log_4{44} \right\rceil = 3.0 $$

and one, score 0.3852:

$$ \log_4{44} \approx 2.729716. $$

This doesn’t seem to be the type of question that calls for spoiler hiding, correct me if I’m wrong.

  • 3
    $\begingroup$ That is extremely impressive! $\endgroup$ – Dark Malthorp May 5 '20 at 12:41
  • 2
    $\begingroup$ "This doesn’t seem to be the type of question that calls for spoiler hiding" - all other answerers seem to disagree. $\endgroup$ – Steve May 5 '20 at 13:50


is equal to

the common approximation $22/7$

and scores


which is $\approx0.4830$.

Edit: Better yet is


which scores


, or $\approx0.5614$.

  • $\begingroup$ Nice. But how did you score it- how many operations did you charge yourself? I count 4, but I think you may have calculated score with 3. And maybe the charge is 5? $\endgroup$ – Damila May 5 '20 at 4:17
  • $\begingroup$ @Damila, it looks like six operations to me. I think that's how I computed the score, but if I messed up then please let me know. $\endgroup$ – msh210 May 5 '20 at 4:25
  • 1
    $\begingroup$ @Damila he did score it correctly $\endgroup$ – Ankit May 5 '20 at 4:37
  • $\begingroup$ I missed the round down symbols. Well done! $\endgroup$ – Damila May 5 '20 at 12:00

Okay, I'll start us off with the obvious:

$\lfloor4\rfloor$ scores $\approx0.0663$.

Surely that can be improved on….

  • $\begingroup$ Good start! Yes it can be improved on though. Since the question, the best I've got is about 0.2 $\endgroup$ – Dark Malthorp May 5 '20 at 2:37
  • $\begingroup$ Lol Nice observation $\endgroup$ – Ankit May 5 '20 at 2:43

Now I've got it ! Just finished generating all possible solutions for a given number of operations. Had to discard some answers because of float overflow so I hope big numbers means lower score.

Best scores up to 5 operations were found by Roman Odaisky and zixuan. Here's a solution for 6 operations :

$\sqrt[4!]4!+4-\sqrt 4 = 3.14158644$

with a score of 0.86778360, but it's still less than the best 5-operation answer.

Program crashed pretty hard at 7 operations though.

Here's the source code.

Old answer

I had an idea how to brute force the whole thing : concatenation is free, so why not use it to its full potential ? With $log_a$ or $\sqrt[b]a$, you'll get only 1 operation so a higher score, and with as many fours you want you might get to $\pi$.

I just realized while writing this that you need four fours or less, so my scores don't qualify.

I used python for precision (tried C++ first but FP64 isn't enough), and used a nested loop to generate numbers of concatenated fours $a$ and $b$, computed $log_b a$ and its score and returned the best score and values (it's $O(n^2)$ so I didn't push it too hard, took 5 minutes) so the best answer for $a$ and $b$ $< 10^{2000}$ is :

$A = 3.141596697042137$ with a score of $5.393247671097606$ for :

$log_b a$ with $a$ being 1680 concatenated fours and $b$ being 535 concatenated fours.

I'll try going at it later by brute forcing all possible operations though, with a acceptable amount of fours.

  • $\begingroup$ You can only use up to 4 fours. $\endgroup$ – Dark Malthorp May 22 '20 at 17:52
  • 1
    $\begingroup$ Yes I realized this too late, but this gave me the motivation to work on brute forcing the original problem, which is a bit more complex. Still working on it. $\endgroup$ – Sarah May 23 '20 at 23:05
  • $\begingroup$ Updated the answer $\endgroup$ – Sarah May 24 '20 at 4:19

3.160964... in 4 operations, score 0.42820978

$\log_{4}(4(4!-4)) $


Got it down to 3.14 but it uses sin again: Score: 1.38767676535

4+sin444 = 3.13991521562

Ok this is extremely close with 2 ops. (3.18): Score: 0.71908465944


I'm not sure if this is legal cuz it uses sin: Score: 0.49654277813


Very close approximation (3.1): Score: 0.44995372319


Really simple one lol works surprisingly well: Score: 0.42447963952

4 - 4/4 = 3

Extremely close (3.16) but 4 operations Score: 0.42108608415


This one is really close (3.18) but uses more operations: Score: 0.33056528095

sqrt4 + (4+4)th root(4)=3.189207115

Heres one with just one operation: Score: 0.29569382019

log(4444)= 3.64777405027

  • $\begingroup$ It seems sin and ln and log with no explicit base are not legal. $\endgroup$ – msh210 May 5 '20 at 3:24
  • $\begingroup$ @msh210 yeah probably $\endgroup$ – Ankit May 5 '20 at 3:28
  • $\begingroup$ @Ankit indeed they are not. $\endgroup$ – Dark Malthorp May 5 '20 at 3:32
  • $\begingroup$ but can you do log base 4? $\endgroup$ – new QOpenGLWidget Jul 21 '20 at 12:25

This isn't legal, but

$\sqrt{4} \times \arccos(4-4) = \pi$

with a score of $+\infty$

  • $\begingroup$ Yes there's a reason I disallowed inverse trig functions / complex logarithms $\endgroup$ – Dark Malthorp May 5 '20 at 5:02
  • $\begingroup$ :) (extra characters to pad the comment) $\endgroup$ – shoover May 5 '20 at 5:04
  • $\begingroup$ @FlorianF Fewer operations ;) $\endgroup$ – Guimoute May 24 '20 at 18:23
  • 1
    $\begingroup$ $4 \times arctan(4/4)$ uses fewer operations, so it scores a larger infinity than yours. [grammar fixed] $\endgroup$ – Florian F May 24 '20 at 18:44

$\sqrt[4]{4!*4} \approx 3.13016916015$

Only used $4-\frac{4}{4}$ operations and $4-\frac{4}{4}$ $4$s. Score:


Please allow this answer. I took $4$ hours to find this answer (or a very long time).


If this is legal:

4/ (4!th root of 44)



With 3 operations

Division, factorial, root. Parentheses not necessary, added for clarity without full mathematical notation.

For a score of 0.187

  • $\begingroup$ I didn't say roots were allowed, but this and one other answer are very creative. I'll allow it. $\endgroup$ – Dark Malthorp May 5 '20 at 4:32
  • $\begingroup$ I have another answer. Posted as a different answer. Got it down to 3.18 $\endgroup$ – Damila May 5 '20 at 5:05

Second answer, got it to 3.18 with 5 operations:

4 - SQRT(4*4/4!) = 3.1835

Score = 0.276


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.