Recently I started being very fascinated in logistics, and out of the blue came the question into my head, what is the factorial of the amount of atoms in the observeable universe, which is said to be between 1,e+78 and 1,e+82 but the amount of ways you can arrange these atoms is unimaginably larger. So I played with this number and I thought it might be interesting to see how far I could get on calculating the factorial of 1,e+80, so I went ahead and created a simple java program:

import java.awt.Color;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Factorial {

    public static void main(String[] args) {
        JFrame frame = new JFrame("Project Factorial");
        frame.setLocation(0, 0);
        JLabel label = new JLabel();
        BigDecimal atoms = new BigDecimal("1E+80");
        BigDecimal total = new BigDecimal("1");
        double increment = new BigDecimal("100.0").divide(atoms)
        double percentage = increment;
        for (BigDecimal num = new BigDecimal("2"); num.compareTo(atoms) <= 0; num
                .add(BigDecimal.ONE)) {
            total = total.multiply(num);
            percentage += increment;
            label.setText("[" + String.format("%-10.3f%%", percentage) + "]"
                    + format(total, total.scale()));

    private static String format(BigDecimal x, int scale) {
        NumberFormat formatter = new DecimalFormat("0.0E0");
        return formatter.format(x);


Quickly after running this program for about an hour I realized running this kind of calculation on any computer today would absolutely take ages, I was hopping to reach 0,001 % on the calculation but it is certainly too large to calculate, but then the question came up, exactly how long would it take? That question is not so easy to answer considering there is alot of factors involved, but really what I am trying to solve is the factorial of 1,e+80.


The number can be very hard to understand just how big it is, so I'd like to visualise how big that number is, for instance, if you could calculate how long it would take for a computer to calculate the factorial of 1,e+80 that would be a cool visualization.

(EDIT: Thanks for the great answers, however, I wish to implement a way of calculating the factorial of 1,e+80 in a application despite I would need to use some kind of approximation formula, so I decided to use Stirling's approximation based on derpy's answer. $$n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n$$ So with Stirling's approximation and GMP library for C programming language it would be possible to make a quite accurate and efficient program to calculate the factorial of 1,e+80 )

  • 5
    $\begingroup$ The factorial runs in linear time with respect to the input. It would take approx. $1\times10^{71}$ seconds on a 1 GHz computer. $\endgroup$
    – apnorton
    Apr 29 '14 at 15:08
  • $\begingroup$ @anorton fascinating, how did you come up with that conclusion? $\endgroup$
    – Linus
    Apr 29 '14 at 15:17
  • $\begingroup$ Back in 2002 I posted some essays in sci.math that you might be interested in. BIG NUMBERS #1; BIG NUMBERS #2; BIG NUMBERS #3 Regarding factorials of numbers, see D. FACTORIALS OF LARGE NUMBERS in essay #2. $\endgroup$ Apr 29 '14 at 15:18
  • 1
    $\begingroup$ Another visualization method would be the number of digits, which, if you wrote down one digit per second, it would take you many times the age of the universe to finish writing. $\endgroup$ Apr 29 '14 at 15:18
  • 2
    $\begingroup$ @Aidan F. Pierce: The number of digits is about $10^{82},$ the number of seconds in $30$ billion years (overestimate by about a factor of $2)$ is about $10^{18},$ so the "many times" works out to more than $\frac{10^{82}}{10^{18}} = 10^{64}.$ $\endgroup$ Apr 29 '14 at 15:27

With the help of wolfram alpha you get an approximation of the number in basis 10 $$ 10^{10^{10^{1.9133}}} $$ Check here other information that should give you an idea of how big the number is.


Easiest way to estimate that number is to employ the Stirling approximation: you have

$$ n! \sim \sqrt{2\pi n}\left(\frac{n}{e}\right)^n $$

(this is asymptotic notation), or even more roughly speaking, $ n! \approx e^{n\ln n} $ as order of magnitude. In your case, say $ n = 10^{80} $, you have

$$ n! \approx e^{80\cdot\ln{10}\cdot10^{80}} \approx 10^{10^{81.9}}. $$

(EDIT: I had written 81 instead of 81.9 at the exponent; not only was the rounding incorrect, but especially, rounding exponents needs a lot of care when talking about orders of magnitude!)

By the way, this is also the plausible order of magnitude (in natural units) for the volume of the phase space of the observable universe.

Pictorially speaking, the decimal expansion of this number would need to convert every single particle in the observable universe into a digit in order to be written out.

For an even more pictorial comparison, the age of the universe is thought to be about $ 10^{17} $ seconds. This is far less than the number of digits you would need to write out the above number. Even if you could churn out, say, a billion of digits per seconds, you would still need about $ 10^{82}/10^9 = 10^{73} $ seconds to complete the task, which is a ridiculously prohibitory amount of time.

  • $\begingroup$ Very nice visualization, although Umberto's answer of the factorial of 1,e+80 is not consistent with your answer. Or am I wrong? $\endgroup$
    – Linus
    Apr 29 '14 at 15:33
  • $\begingroup$ @Linus: Well, $ 10^{1.9133} \approx 81 $, so I would call that consistent. :) (More like 82, actually, but Wolfram Alpha is probably better at estimating numbers than I am in the span of a few minutes XP). $\endgroup$
    – derpy
    Apr 29 '14 at 15:35
  • $\begingroup$ Okay thanks, but shouldn't it be something like 10^10^10^81 instead of 10^10^81? $\endgroup$
    – Linus
    Apr 29 '14 at 15:37
  • $\begingroup$ @Linus: Count the number of 10's carefully: $ 10^{10^{10^{1.9133}}} = 10^{10^{81.9}} $ upon replacing the final $ 10^{1.9133} $ with 81.9. $\endgroup$
    – derpy
    Apr 29 '14 at 15:41
  • $\begingroup$ Opps, my mistake, thank you! $\endgroup$
    – Linus
    Apr 29 '14 at 15:42

For the computation time aspect of the question:
Let's assume that a single multiplication takes "constant" time (and that we can perform ~$10^9$ such operations in a second--a reasonable approximation with today's processor).

To compute the factorial of $n$, you must perform $n$ multiplications. Recall that we can perform $10^9$ multiplications per second. So, the runtime of that factorial is: $$\frac{10^{80} \text{ multiplications}}{10^9 \text{ multiplications per second}} = 10^{71}\text{ seconds} \approx 3\times 10^{63} \text{ years}$$

Basically, you'll never see that factorial program terminate.

  • 10
    $\begingroup$ Notice that a key assumption is that we can perform any multiplication in the same amount of time--one nanosecond. This is a little absurd, since bigger numbers will take longer to multiply. But, this at least provides a lower bound for the runtime of the algorithm. $\endgroup$
    – apnorton
    Apr 29 '14 at 15:25
  • $\begingroup$ That is mindblowing, I would give you a vote but my rep is too low.. $\endgroup$
    – Linus
    Apr 29 '14 at 15:36
  • 6
    $\begingroup$ And since it's written in Java it'll take even longer! $\endgroup$
    – Mike G
    Apr 29 '14 at 18:56
  • 4
    $\begingroup$ If you believe in Moore's Law, you should wait quite a while before starting the program. If it takes more than four years to run, wait two years and the speed will double, so you finish faster. You need about 208 doublings to get the runtime down to four years, so wait 516 years and run the program, finishing in 520 years. $\endgroup$ Apr 29 '14 at 19:09
  • 2
    $\begingroup$ @Linus: Not necessarily. As far as my understanding goes, quantum computing can be helpful when large parallelization is required, but if you need to just perform a bunch of sequential operations, "classical" (binary) computing could still prove faster (not to mention easier to implement). $\endgroup$
    – derpy
    Apr 30 '14 at 12:49

The usual function for working with big numbers like this is not $\Gamma(x)$ but $\log\Gamma(x)$ which increases only slightly more than linearly. So



1.832068074395236547214393164 E82

in PARI/GP, meaning that $$ (10^{80})!\approx\exp\left(1.832068074395236547214393164\times10^{82}\right) $$ which is about $$ 10^{79565705518096748172348871081083394917705602994196333433885546216834135350791129623} $$ or $$ 10^{10^{81.9007}}. $$


And this assumes the possible arrangement of particles if its assumed they are bound to fixed locations in space. To work out how many permutations there are of particles within space you could then consider how many spacial positions there are by assuming a cubic planck length...

And then permutate that again for time, again assuming planck time as the smallest possible time interval...


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.