Skip to content

factorial_stirling

Vašek edited this page Feb 6, 2019 · 1 revision

factorial_stirling

This function returns Stirling's approximation of the factorial of the given number

Syntax:

factorial_stirling(n)
Argument Description
int n The given number

Returns: int

Description:

Stirling's approximation (or Stirling's formula) is an approximation for factorials. It is a good approximation, leading to accurate results even for small values of n. This function is much way faster then factorial.

Example:

int value = factorial_stirling(5);

This Function will set value to 118. Correct result of 5! is 120, so the acuraccy for number 5 is 98,3%.

Example 2:

int value = factorial_stirling(10);

This Function will set value to 3598695. Correct result of 10! is 3628800, so the acuraccy for number 10 is 99,17%.

Back to number_functions

Clone this wiki locally