Mathematicians needed more than the simple four operations: discover how punctuation entered your homework with our factorial calculator. With this simple tool, you will learn:
- What is the factorial of a number;
- How to calculate the factorial of a number;
- How probabilities and factorials are connected; and
- The factorial, but for addition.
And there will be space for something more!
What is the factorial of a number?
The factorial of a number is the product of all the integer numbers smaller and equal than the number itself.
Factorials appeared spottily during history, with some references to products of subsequent integers in antiquity, in particular related — more or less indirectly — to the computation of combinations. Only in the 15th century did mathematicians start a more detailed analysis of the operator, with the first tables and analysis of properties.
From then on, the factorial imposed itself as a cornerstone of math, particularly combinatorics. Physics makes extensive use of the operator, particularly in the field of statistical mechanics. For reasons we will discover soon, computer scientists use this operator to explain a particular way of writing code.
At the beginning of the XIX century, the mathematician Kramp introduced the notation of an exclamation mark to denote a factorial, opening the gates to a plethora of bad math jokes!
How to calculate the factorial of a number?
To calculate the factorial of a number , simply write down the integers number leading up to , and multiply them:
This is pretty easy, right? Let's calculate the first five factorials:
Now let's try to calculate the factorial of... . Let's try to do this by hand:
Ok, too big. Input in our... exclamation point calculator! 😉
Damn! This is a huge number. Factorial behave like this, exploding quickly and becoming harder and harder to compute. During calculations is better to keep them not expanded, or only in the measure you need to perform some needed simplifications.
Did you see the long series of zeros at the end of ? We call them *trailing zeros, and they are the result of multiplications by , and occasionally by its prime factors (only when it multiplies ), and (only when it multiplies even numbers). Note that the second condition automatically implies the first one.
Factorials have a nice property with large uses:
And so on. Apart from being fundamental in physics due to many possible approximations when factorials appear in fractions, this property is appreciated by computer scientists since it is a neat example of recursion.
If you tell your computer to multiply a number by the same number minus , and to do so giving as argument of the same operation the same number minus , and to stop when the number minus is equal to , you quickly compute the factorial of a number. In pseudocode, this would look like this:
The function obviously returns .
What is the factorial of 0?
The factorial of is tricky. Take the definition of factorial, and apply it to this number:
Yes, it's kinda broken. We use the following convention:
In the next section, we will see why it makes sense!
Applications of the factorial formula
The factorial formula has a neat interpretation as the number of possible ways to arrange a set of objects (permutation). If you have five friends, you can create possible "queues" with them.
Factorials have a fundamental role in the definitions of combinations, too: the binomial coefficient defines how many ways to arrange objects in groups with size there are:
Imagine having objects. How many ways to choose all of them are there? One, of course: you simply pick all the objects together. Let's call the binomial coefficient in our help, with :
It is clear that .
Factorials often appear in power series, as in the one for the exponential function:
Factorial, but for addition
What about addition? Can't we define an operator similar to the factorial but for the sum of subsequent numbers, and not multiplication?
The answer is yes: it also got an unofficial name by the famous computer scientist Donald Knuth. The termial operator applied to a number is defined as the sum of every positive integer leading to . We can (ironically) mark it with a question mark:
The termial of a number doesn't have as many applications as the factorial. However, a similar concept surfaces when talking of triangular numbers: the succession of those particular numbers (numbers you can fit in an equilateral triangle) follow the terminal:
The first termial numbers are:
How to calculate the factorial of a number without going crazy: the Stirling's approximation
Calculating the factorial using discrete integer numbers can be tedious, and the resulting function is hard to plot — and even to imagine. Stirling, a Scottish mathematician, published his finding on the relationship between the logarithm and the factorial operator in 1730. Using the property of logarithms, we can write:
Taking the limit of the sum (the integral), we write the approximate result:
The factor can be neglected for big numbers. You just discovered a life-saving approximation for many physicist!
On the other hand, we use logarithms, e.g., to convert sound intensity to decibels. We have a dedicated tool for that topic so be sure to check it!