[157510 views]
Product of all consecutive Integer numbers up to n is called Factorial of a Number and is denoted by n! For Example, the value of 5! is 120.
Mathematically it is written as,
n! = 1 * 2 * 3 * 4 * ... * (n-1) * n
For example, the factorial of 5 is,
5! = 1 * 2 * 3 * 4 * 5 = 120
We first take input from user and store that value in variable named “n”. Then we initialize a variable “Fact” with value 1 (i.e Fact=1) and variable i with value 1(i.e i=1). Repeat next two steps until i is less than n.
Let’s take an example,
Let the input be 5.
The equation that gets created by our algorithm is 5x4x3x2x1.
So, The Factorial of 5 is 120(5x4x3x2x1).
Super definition awesome I am intelligent so I can able to understand this concept .