What's the closest approximation to $\pi$ achievable using each digit $0-9$ no more than once, and basic operations of roots, brackets, exponentiation, addition subtraction, concatenation, division and factorial?

This was mentioned in another question and I thought it was fun. I can pretty quickly come up with (with a bit of help from Ramanujan):


I challenge anybody to get beyond 20 decimal digits of accuracy!

  • 13
    $\begingroup$ futilitycloset.com/2017/03/16/pandigital-pi $\endgroup$ – Jack D'Aurizio Jan 3 '18 at 23:12
  • 2
    $\begingroup$ Can you prove that more than 20 is achievable? $\endgroup$ – user480281 Jan 4 '18 at 1:03
  • $\begingroup$ Does each digit have to be used once? $\endgroup$ – gen-z ready to perish Jan 4 '18 at 1:41
  • $\begingroup$ @ChaseRyanTaylor Nope, no more than once includes those that are not used at all, or used zero times. $\endgroup$ – user480281 Jan 4 '18 at 1:45
  • $\begingroup$ @Adeen no but I think Jack's linked article suggests it may be. The factorial is very useful. $\endgroup$ – samerivertwice Jan 4 '18 at 4:45

10 Answers 10


We will use notation $\sqrt{^{n}\;x}\quad$ for $n$ nested square roots (see tehtmi's answer): $$\sqrt{^{n}\;x} = \underbrace{\sqrt{\sqrt{\cdots \sqrt{\sqrt{x}}}}}_{n} = \sqrt[2^n]{x}.$$

Here is one example:

this formula is pandigital one; it uses all mentioned operations excluding exponentiation. $$ \sqrt{\dfrac{8}{\sqrt{^2\;9}}} + \sqrt{\vphantom{\dfrac{8}{8}}^{8}\; \dfrac{\sqrt{^9\; \sqrt{6!} + \sqrt{^{11}\; \left( \sqrt{^8\;4} + \dfrac{1}{\sqrt{^{16}\;2}} + \sqrt{^9 \left(\sqrt{^7\;5!} - \sqrt{^{16}(3!-0!)}\right) } \right) }}}{7} } \\ \approx 3.14159\;26535\;89793\;23846\;26\color{Tan}{610} \approx \pi + 1.766\times 10^{-23}; \tag{P.1}$$

By steps:

$a = \sqrt{^7 \; 5!} - \sqrt{^{16}\;(3!-0!)} \approx 0.03808 59887 98727 14645 $;

$b = \sqrt{^8 \; 4} + \dfrac{1}{\sqrt{^{16}\;2}} + \sqrt{^9\; a} \approx 2.99905 70159 26621 87896$;

$c = \sqrt{6!} + \sqrt{^{11}\;b}\approx 27.83335 21520 97348 95023$;

$d = \dfrac{\sqrt{^9\;c}}{7}\approx 0.14378 82430 20488 46604$;

$\pi \approx \sqrt{\dfrac{8}{\sqrt{^2\;9}}} + \sqrt{^8\; d}$.

Simplified WolframAlpha checking code:

sqrt(8/sqrt(3)) + ( ( sqrt(6!) + (4^(1/256) + 2^(-1/65536) + ( (5!)^(1/128) - 5^(1/65536) )^(1/512) )^(1/2048) )^(1/512) /7 )^(1/256) - pi

How it can be obtained:

Note that when we will use one digit, we can approximate number $\pi$ to $2$ decimal digits: $$ \sqrt{^{15} \; (7!)!} \approx 3.1\color{Tan}{822} \approx \pi + 4.067 \times 10^{-2}; \tag{1} $$

$2$ used digits: $4$ decimal digits of accuracy: $$ \sqrt{\sqrt{5!} - \sqrt{^7\;7!}} \approx 3.141\color{Tan}{349} \approx \pi - 2.435\times 10^{-4}; \tag{2} $$

$3$ used digits: $7$ (and maybe more) decimal digits of accuracy: $$ 2 + \sqrt{\vphantom{\dfrac{1}{1}}^{\:6} \; \dfrac{7!}{\sqrt{^8 \; 9!}}} \approx 3.14159\;2\color{Tan}{576} \approx \pi -7.676 \times 10^{-8}; \tag{3} $$

$4$ used digits: $11$ (and maybe more) decimal digits of accuracy: $$\sqrt{^{5} \; \sqrt{^8\;8!} - \sqrt{^{14}\;7!}} + \sqrt{6 - \sqrt{^{16}\; 3!}} \\ \approx 3.14159\;26535\color{Tan}{682} \approx \pi - 2.157 \times 10^{-11}; \tag{4} $$

$5$ used digits: $13$ (and maybe more) decimal digits of accuracy: $$ \sqrt{\dfrac{8}{\sqrt{^2\;9}}} + \sqrt{\vphantom{\dfrac{8}{8}}^{8}\; \dfrac{\sqrt{^9\; \sqrt{6!} + \sqrt{^{11}\;3}}}{7} } \\ \approx 3.14159\;26535\;89\color{Tan}{835} \approx \pi + 4.178\times 10^{-14}; \tag{5} $$

Now, replacing the digit "$3$" in $(5)$ by appropriate expression constructed of digits $0,1,2,3,4,5$, we get $(P.1)$ which approximates number $\pi$ with accuracy of $>20$ decimal places.

Approximation without $!$ and $\sqrt{\phantom{88}}$ : $$\Large 3 + \dfrac {9^{^{\frac{2}{5\cdot 7} - \left(1+6\right)^{-4}}}} {8} = 3+ \dfrac{9^{\frac{2}{35}-\frac{1}{2401}}}{8} \\ \approx \normalsize 3.1415926535 \color{Tan}{916} \approx \pi +1.875\times 10^{-12}.\tag{P.2}$$

(see Pi Estimation using Integers for more info).

Another approximation (without multiple square roots):

$$ \left(\sqrt{3!}-\sqrt{\sqrt{90-2}-6}\right) \times \sqrt{1+(4+5)\sqrt{8}} + 0\times 7 \\ = \left(\sqrt{6}-\sqrt{\sqrt{88}-6}\right) \times \sqrt{1+9\sqrt{8}} \\ \approx 3.1415926535897\color{Tan}{423} \approx \pi - 5.089\times 10^{-14}.\tag{P.3} $$ (see The Contest Center - Pi for similar examples).

Some approximations can be derived from Pi Approximations.

  • $\begingroup$ Good work! I know of no result longer than 20 digits yet. I hoped the roots and factorial could make this possible. $\endgroup$ – samerivertwice Jan 5 '18 at 15:19
  • $\begingroup$ @Robert Frost: huh, I constructed one appropriate formula recently. $\endgroup$ – Oleg567 Jan 11 '18 at 16:33
  • 1
    $\begingroup$ Personally I count $\sqrt{^n x}$ as using $n$. Not doing that is like saying $4\times 3$ doesn't use $3$ because its equal to $4+4+4$. That the latter couldn't be used because $4$ is used more than once doesn't change my POV. $\endgroup$ – SK19 May 10 '18 at 14:39
  • 5
    $\begingroup$ @SK19: the difference is: I can easily replace expression $$\sqrt{^7 5!}$$ with $1$-digital expression $$\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{5!}}}}}}},$$ but you cannot replace expression $$4\times 3=4+4+4$$ with another $1$-digital expression with digit $4$ (using operations mentioned above). $\endgroup$ – Oleg567 May 12 '18 at 11:55

$\frac{\log (5280^{\sqrt{9}} + 3!! + 4! )}{1 \times \sqrt{67}} \approx 3.14159265358979324$, good for 18 places

If you don't like logs,
$(8\times9 +\frac{52-0!}{73})(\sqrt{-1}^{\sqrt{-4}}) \approx 3.14159266$, good for 8 places of accuracy.

$\sqrt{\sqrt{\frac{2143}{5!!+7}}} \approx 3.141592653$, good for 9 places of accuracy.

$3 \sqrt{\sqrt{\sqrt{\sqrt{\sqrt{\sqrt{20-\frac{4\times8}{9\times5 - 7 - 1}}}}}}} \approx 3.141592652$, good for 9 places of accuracy.

For $e$, I challenge people to beat Sabey's approximation of $(1+9^{-4^{7\times6}})^{3^{2^{85}}}$, which is only accurate to 18457734525360901453873570 decimal digits.

  • 2
    $\begingroup$ Very nice. Unfortunately, the question does not list logarithms as a permissible operation. $\endgroup$ – njuffa Jan 4 '18 at 3:14
  • $\begingroup$ We could pretty quickly have log -1 divided by i $\endgroup$ – samerivertwice Jan 4 '18 at 4:42
  • 3
    $\begingroup$ $(\log(-1)^4)^{2/8}-\dfrac{3}{5^{(7^9)}}$. Good to $28,205,960$ decimal places. $\endgroup$ – samerivertwice Jan 4 '18 at 21:34
  • 3
    $\begingroup$ Should we assume that these formulas were just pulled out of thin air, or are there actually methods for finding them? $\endgroup$ – Qudit Jan 5 '18 at 7:25
  • 4
    $\begingroup$ @Qudit, for the first one, I suspect Ed began with the fact that $67$ is a Heegner number, then searched for an appropriate expression to match the integer part of $e^{\sqrt{67} \cdot \pi}$. $\endgroup$ – Dan Brumleve Jan 10 '18 at 22:08

I can't prove this, but I think we may be able to get as close as we want by starting with $1234567890$, taking some number of factorials, and then taking square roots until we get a number less than $\pi^2$. Heuristically we get a random number in the interval $[\pi, \pi^2]$ whose logarithm is uniformly distributed so we ought to be able to get as close as we like to $\pi$ by taking enough factorials.

  • $\begingroup$ You might be right but let's see it! $\endgroup$ – samerivertwice Jan 4 '18 at 4:42
  • $\begingroup$ I'm not even sure how to compute it with two factorials, I think Stirling's approximation is going to lose too much precision. It may not be provable, Brocard's problem seems sort of related, if we think of it as saying that we can find factorials whose square roots are arbitrarily close to integers. $\endgroup$ – Dan Brumleve Jan 4 '18 at 4:46
  • $\begingroup$ I had a similar idea to yours with 4 repeated factorial over 3 repeated factorial which may be easier to work with. $\endgroup$ – samerivertwice Jan 4 '18 at 4:50
  • $\begingroup$ Yeah, we get a lot more combinations by breaking up the factorials and square roots with other operations. Factorial and square root are the only unary operations that don't use digits though so we have to use arbitrarily many of each. If we interpret factorial as $\Gamma(x-1)$ then I think we can approach $\pi$ by applying $\sqrt{x}$ until it's less than $\pi$, $\Gamma(x-1)$ until it's greater, $\sqrt{x}$ again until it's less, etc. In that case we can at least compute it to see if it works. $\endgroup$ – Dan Brumleve Jan 4 '18 at 4:58
  • 6
    $\begingroup$ Unfortunately I don't think we should be allowed to use factorials of non-integers (i.e. Gamma function) because it is possible to build $\pi$ exactly: $\pi = (3/2)!*(6/4)!*(8/9)*(7-5)*(1+0)$ $\endgroup$ – Tob Ernack Jan 6 '18 at 20:21

Cheating a little with decimal points, but very, very simple:

$3.8415926 - 0.7$


$3 + 1/7 - (6/((9480/2)+5)) \approx 3.1415926539214 \approx \pi + 3.316 \times 10^{-10} $

  • $\begingroup$ Good work! Nothing wrong with those as far as I'm concerned. $\endgroup$ – samerivertwice Jan 4 '18 at 10:55

My answer uses lots of nested square roots, so I'll write $n$ nested square roots on $x$ as $\sqrt{^n x}$ to avoid writing them all out. Evaluated with Wolfram Alpha.

$$\sqrt{^5 70} - \sqrt{^{15} 9!} + \sqrt{^{23} 8!} + \sqrt{^{34} 14!} + \sqrt{^{36} .5} + \sqrt{^{41} 2} - \sqrt{^{46} .6} \approx \pi + 5.477.. \times10^{-16} $$

Here's something that should be equivalent that can be plugged into Wolfram Alpha: 70^(1/2^5) - 9!^(1/2^15) + 8!^(1/2^23) + 14!^(1/2^34) + (5/10)^(1/2^36) + 2^(1/2^41) - (6/10)^(1/2^46)

Basically, the fractional part of $\sqrt{^5 70}$ is a good approximation for the fractional part of $\pi$. Then the fractional part of $\sqrt{^{15} 9!}$ is a good approximation for the remaining fractional part error. And so on, with a bit of finesse to make the integer part work out nicely. Chaining a bunch of square roots on anything will always give something that helps at least a little, since you can get numbers arbitrarily close to $1$. I did a fairly simple greedy search.

Surely it is possible to do better with this approach, but I was about to the point where double precision floating point runs into trouble representing $(1 \pm \text{error})$ anyway.

  • 1
    $\begingroup$ + Very promising approach! $\endgroup$ – Oleg567 Jan 5 '18 at 13:54
  • $\begingroup$ Getting closer to that magical 20 decimal digits! $\endgroup$ – samerivertwice Jan 5 '18 at 14:13
  • $\begingroup$ @RobertFrost but the digits from 0-9 were to be used only once? $\endgroup$ – user427802 Dec 8 '18 at 15:28
  • 1
    $\begingroup$ @AbhasKumarSinha This answer could be written out with exactly 200 square root signs, and that would be silly so I permitted it to be abbreviated like this. $\endgroup$ – samerivertwice Dec 8 '18 at 15:46

$$\frac{354 + (0!)^8}{\sqrt{12769}} = \frac{355}{113} \approx 3.1415929203$$ which is close to $\pi$ with an error absolute value of $2.6 \times 10^{-7}$.

This comes from one of the convergent approximations of the continued fraction expansion of $\pi$.

I am trying to find a slightly more accurate variation of this.

EDIT: This is a very liberal interpretation of the rules, but if we allow factorials of non-integers then we can obtain an exact formula for $\pi$, such as:

$$\pi = \left(\frac{3}{2}\right)!\times\left(\frac{6}{4}\right)!\times\frac{8}{9}\times(7-5)\times(1+0)$$

This uses the fact that $\left(\frac{3}{2}\right)! = \Gamma\left(\frac{5}{2}\right) = \frac{3\sqrt{\pi}}{4}$ (there's probably other nicer variations).


A simple exact expression using the gamma function: $$\left(\frac63\cdot\left(\frac48\right)!\right)^2$$

My answer below, based on tehtmi's answer, has two more decimal digits of accuracy. It applies a factor to the sum of the first five terms instead of adding two more terms.

$$(\sqrt{^5 70} - \sqrt{^{15} 9!} + \sqrt{^{23} 8!} + \sqrt{^{34} 14!} + \sqrt{^{36} .5}) * \sqrt{^{44} 6} * \sqrt{^{50} 2} * \sqrt{^{58} 3} \approx \pi - 1.926.. \times10^{-18} $$

The equivalent expression here can be plugged into Wolfram Alpha: (70^(.5^5)-9!^(.5^15)+8!^(.5^23)+14!^(.5^34)+.5^(.5^36))*6^(.5^44)*2^(.5^50)*3^(.5^58)


Taking inspiration from @Dan Brumleve's answer, we could attempt to use nested square-roots, factorials and concatenations (i.e. floor and ceiling functions) to find integers whose ratio is arbitrarily close to $\pi$.

Various people have previously studied whether you can get every integer from nests of roots, factorials and concatenations, possibly only using the number $3$. Here are a few links to discussions on the topic:

I will be taking the floor of each square-root value, to make sure no factorials of non-integer arguments are taken. You don't have to do this, and you may find more numbers are possible when taking repeated square-roots. But you may need to be wary of only taking a factorial after a floor or ceiling function.

Define the string $3FSS\ldots$ to be the order of factorials ($F$) and floors of square-roots ($S$), read left to right. For example, $3FSFF$ would represent $\left(\left\lfloor\sqrt{3!}\right\rfloor!\right)!=2$. Also, for neatness' sake, let $S_n=\underbrace{S\ldots S}_n$

The following table shows some possible values with this method.

$$\begin{array}{|c|c|} \hline \text{number} & \text{generating string} & \text{algebra} \\ \hline 1 & 3S & \lfloor\sqrt{3}\rfloor \\ 2 & 3FS & \lfloor\sqrt{3!}\rfloor \\ 3 & 3 & 3 \\ 4 & 3FFSFS_4FS_5FS_7 & \ldots \\ 5 & 3FFSS & \left\lfloor\sqrt{\lfloor\sqrt{(3!)!}\rfloor}\right\rfloor \\ 6 & 3F & \lfloor\sqrt{3}\rfloor \\ \hline \end{array} $$

Hence, we can say that: $$\pi\approx\frac{3F_2S_2FSFS_2FS_4}{3F_2SFS_4FS_5FS_6FS_3}=\frac{1989}{633}=\color{red}{3.14}218\ldots$$

Therefore, we can get the first $3$ digits using only the number $3$. This could easily be extended to avoiding using $3$ twice, by replacing $3F$ with $6$.

We could further extend this technique by:

  • Nesting operations on the digits $4$ to $9$ too and combining the numbers in order to get a more efficient representation of $\pi$.
  • Combining the nests of operations with different digits (e.g. $\sqrt{3!+4!}$).
  • Proving whether all integers are reachable with this method, which would trivially prove that arbitrarily accurate approximations of $\pi$ are possible.

My very messy and un-pythonic python code used to generate the above formulae is provided here.


With 8 digits and with paper-and-pencil and Wolfram Alpha, I obtained:

$$\sqrt[8]{{7!}}+\frac {2}{9}+ \frac{5-4}{60} \approx 3.1416000$$


Very "bad" approximation with all digits and only three elementary operations:

$$3+\frac{1}{7}+\frac{2 \cdot 5}{809 \cdot (6+4)} \approx 3.1440$$


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.