Factorial of a number


A factorial is a function in mathematics with the symbol (!) that multiplies a number (n) by every number that precedes it. In simpler words, the factorial function says to multiply all the whole numbers from the chosen number down to one. In more mathematical terms, the factorial of a number (n!) is equal to n(n-1). For example, if you want to calculate the factorial for three, you would write

3! = 3 x 2 x 1 = 6

What does this mean? So, let's assume we have a, b and c as any object. On how many different ways can we arrange these elements (unique way)? Well, factorial function just told us. Six times. Let's see if that's true.

a b c
a c b
b a c
b c a
c a b
c b a

That's right, numbers don't lie, we have six possible arrangements for 3 elements. Another example with this would be, how many possible number can there be with 3 digits? Of course, 3 given digits. Let's say digits are 1, 2 and 3.

123
132
213
231
312
321

General formula of factorial can be written like this:
$$\mathit n! = n * (n - 1)$$

That's it. With these 3 digits we can write 6 numbers. Cool, is it not? How about you try by yourself for 4? Try it on your own and then check the solution:

Solution for factorial of 4 :


Now, here is a tricky thing that you might ask. What is factorial of zero. Say whaaaat?? Well, factorial is used to calculate permutations or possible occurrences of something. Having that in mind, even if you say: How many times I can arrange nothing? Well, one time. If it still sounds puzzling to you, please check this link for additional information about it.

There is no factorial of negative number. This table represents factorials of numbers and you can clearly see how fast it is to grow in number of combinations:

[Tutorial] Factorial of a number Screen20