This article is based on Free Code Camp Basic Algorithm Scripting “Factorialize a Number”

In mathematics, the factorial of a non-negative integer n can be a tricky algorithm. In this article, I’m going to explain three approaches, first with the recursive function, second using a while loop and third using a for loop.

We have already seen a recursion approach on a String in the previous article, How to Reverse a String in JavaScript in 3 Different Ways ? This time we will apply the same concept on a number.