The factorial formula for any positive integer $n$ is: $$n! = n\times(n-1)\times(n-2)\cdots\times 2\times 1$$
$n=0$ is a special case defined as: $$0! = 1$$
Sometimes we may also see the double factorial, which is denoted and defined as: $$n!! = n\times(n-2)\times(n-4)\times\cdots$$
When $n$ is even, the above sequence ends with $2$. When $n$ is odd, the above sequence ends with $1$. For example, $$6!!=6\times 4\times 2=48\quad\text{and}\quad 5!!=5\times 3\times 1= 15$$
Clearly we have $$n! = n!!\times(n-1)!!$$
Tip: When the result is too big to calculate, it is acceptable to just write down the factorial expression. Use $10!$ instead of $3628800$. It is easier to verify the result and also understand how the answer is obtained.
In computer programming, the factorial function can be implemented as a loop by increasing a counter from $1$ to $n$ and calculating the product. Alternatively, it can also be implemented using recursion. Recursion is a powerful method in many mathematical fields including counting. We will discuss this techniuqe in the lesson Recursion.
Using recursion, the factorial function $F(n)$ can be defined in the following way: