Sterling's formula approximates the factorial function with:
N! = Sqr(2 * PI * N) * (N / E) ^ N
This is a fairly good approximation for larger N. For example, when N = 10, the difference between this value and the true factorial is about 0.83 percent.
When you change the value in this program's text box, the code calculates the true factorial and the value given by Sterling's and displays the results and their difference.
|