Introduction To Factorials(n!)

By:Mohammad-Ali Bandzar | July 2 2019

The factorial function in math is written as n!, where n can be any whole number greater than or equal to zero. It is a fancy way of telling us to take the product(multiply) of all whole numbers between 1 and itself together (with zero being a special case we will discuss below).


Shown below is how we would calculate 6!
That same example could be rewritten to the following:

Factorials of 1-10

n n! = =
10 10*9*8*7*6*5*4*3*2*1 10*9! 3,628,800
9 9*8*7*6*5*4*3*2*1 9*8! 362,880
8 8*7*6*5*4*3*2*1 8*7! 40,320
7 7*6*5*4*3*2*1 7*6! 5,040
6 6*5*4*3*2*1 6*5! 720
5 5*4*3*2*1 5*4! 120
4 4*3*2*1 4*3! 24
3 3*2*1 3*2! 6
2 2*1 2*1! 2
1 1 1*0! 1
0 N/A 0! 1

Calculating a factorial

Generally speaking most scientific calculators will have an inbuilt factorial button often labeled n! or x! that will solve for factorials for you, but to gain a better understanding about how they work read on.
From the example above we can see that the factorial of any number is simply itself multipled by the factorial of the number 1 less than itself, which can be written as follows:
we could then simplfy this to the following:
then we could apply the same rule we determined above to the 5!:
This methodology can be applied to any positive integer(with the special case of zero being talked about at the bottom of this page). The sort of general form equation we can develop from this is as follows:

Using product notation

Product notation is just like summation notation(represented by sigma) but instead of adding we multiply(take the product of) succeeding terms.
The factorial of any integer n>0, can be solved using the following product notation equation:
We can also write the definition as a piecewise function to include the 0! case.

The zero case

The factorial of zero is always one, so
Like me, you may believe that this is a rather counter intuitive idea, but it can be justified using the following equation which is based on the one we developed above.
Which we can then rearrange to isolate 0!. loading...

Dividing factorials

The equation above can be expanded to the following:
Then we can cross out like terms to simplify our fraction:
Then we can solve:

Pro tips

Example 1

Let's say that we had 10 friends we wanted to place in line for ice cream and we wanted to know how many different ways we could arrange them. The equation would be as follows:
Explained: We would have 10 friends to choose from for the first spot in line, but only 9 for the second and only 8 for the third so on and so forth.

Example 2

Mike has 10 marbles 5 are red, 2 are blue and 3 are green, in how many different ways can he arrange them into a row? The equation would be as follows:
Explained: We start off by taking 10! because that is the number of marbles Mike has, we then want to divide by 5!, 2! and 3! because those are the sets of the same marbles he has. This is because swaping 2 or more marbles of the same color will have no effect on the way the row of marbles will look and so we want to exclude those cases.


Calculator code

For those who are interested, I have included the calculator code below:

    <input type="number" id="inputFactorial" value="6">
    <button onclick="findFactorial()">Find Factorial</button>
    <p id="output"></p>
        function findFactorial() {
            var x = document.getElementById("inputFactorial").value;
            if(x%1 != 0 || x<0){
                document.getElementById("output").innerHTML = "please enter a valid input";
            }else if(x==0){
                document.getElementById("output").innerHTML = "0";
                var n=1;
                document.getElementById("output").innerHTML = n;