What is Factorial?
In mathematics, the factorial of an integer x is the product of all positive integers less than equal to x, where x is a natural number.
Factorial logic: let the number be x. Therefore, x!= x(x-1)*(x-2)*(x-3)*....*1
For example, the factorial of 5! is 120. By definition 5!=5*4*3*2*1=120
Let's define a function which accepts a number and calculate it's factorial.
We can pass any value to the function by calling it. You can put any positive value to the variable x to calculate the factorial of a number.
As a result, the function works fine till the value of x=21 but fail once we go beyond x value greater than 21.
For example, let's find the factorial of 22 using the above function.
- Integers (numbers without a period or exponent notation) are accurate up to 15 digits.
So, let's find an alternative approach as we are not satisfied with the result for a greater value of x.
I found a great article and approach to this problem by Niel Patel. Niel has beautifully explained the approach as solved this challenging problem.
The above function makes use of another function which is add():
Kindly use this factorial calculator to find the factorial of any positive number.
Hence, This calculator can calculate factorial of large numbers such as 52 factorial, zero factorial, and 20 factorial.
What is 52 factorial?
52 factorial is 80658175170943878571660636856403766975289505440883277824000000000000
what is zero factorial?
factorial of 0 is 1
Why zero factorial is 1?
Zero factorial is 1 because by recursive definition of factorial i.e x!=(x+1)!/(n+1)
As a result, after initializing x with 0 we get the factorial of 0 as 0!=(0+1)!/(0+1).. i.e=1.
What is 20 factorial?
20 factorial is 2432902008176640000.
Go ahead and try with a different number, use the factorial calculator.
Finally, thanks for reading, if the tutorial was helpful to you feel free to comment and don't forget to share.