In probability calculations, we frequently need to compute the value of the factorial of some number n. The factorial of a number n (designated n!) is given by the formula,
n! ← n * (n−1) * (n−2) * ... * 3 * 2 * 1.
When n is a very large number, this is a time-consuming calculation. Fortunately there is a handy formula, called Stirling’s Formula, which gives a very good approximation to n! whenever n is large. Stirling’s formula says:
n! ≈(1 + 1/(12n−1)) * sqrt(2nπ) * (n/E)n
The symbol π is the ratio of a circle’s perimeter to its diameter, and the symbol E is the base of natural logarithms. The actual value of n! is always slightly smaller than the value given by this formula. For this exercise, write a Java code fragment that implements Stirling’s formula.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.