Factorial of 1,e+80

4.6k Views Asked by At

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.setAlwaysOnTop(true);
        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        frame.setLocation(0, 0);
        frame.setUndecorated(true);
        JLabel label = new JLabel();
        label.setForeground(Color.white);
        frame.getContentPane().setBackground(Color.BLUE);
        frame.getContentPane().add(label);
        frame.setVisible(true);
        BigDecimal atoms = new BigDecimal("1E+80");
        BigDecimal total = new BigDecimal("1");
        double increment = new BigDecimal("100.0").divide(atoms)
                .doubleValue();
        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()));
            frame.pack();
            Thread.yield();
        }
    }

    private static String format(BigDecimal x, int scale) {
        NumberFormat formatter = new DecimalFormat("0.0E0");
        formatter.setRoundingMode(RoundingMode.HALF_UP);
        formatter.setMinimumFractionDigits(scale);
        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.

$$(1\times10^{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

There are 5 best solutions below

0
On BEST ANSWER

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.

6
On

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.

15
On

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.

0
On

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

lngamma(1e80+1)

gives

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}}. $$

0
On

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...