The next problem is to find the factorial of a number. A factorial is defined for integers greater than or equal to zero and is defined as:
Now, if you need to find the factorial of a number 'n', you just need to multiply 1 with 2, then the result with 3, succeeded with a multiplication with 4 and so on until 'n'. Sounds like this question needs to be done using a loop. So given a number n, can you find n!? Let's hear from Sajan on how to approach it.
Try and code the above-explained logic. If you feel stuck, Sajan will show you how to convert the above logic in a code in the next video. You will find loops useful in this problem.
Here is the video of Sajan showing how to write a code for this problem using the above-explained logic. But before you hit the 'Play' button, do you want to try it out yourself?