Calculating Factorials using Stirling Approximation | C # program for calculating factorial of a number using Stirling Approximation ; function for calculating factorial ; evaluating factorial using stirling approximation ; Driver Code
class GFG { public static int stirlingFactorial ( double n ) { if ( n == 1 ) return 1 ; double z ; z = System . Math . Sqrt ( 2 * 3.14 * n ) * System . Math . Pow ( ( n / e ) , n ) ; return ( int ) ( z ) ; } public static void Main ( ) { System . Console . WriteLine ( stirlingFactorial ( 1 ) ) ; System . Console . WriteLine ( stirlingFactorial ( 2 ) ) ; System . Console . WriteLine ( stirlingFactorial ( 3 ) ) ; System . Console . WriteLine ( stirlingFactorial ( 4 ) ) ; System . Console . WriteLine ( stirlingFactorial ( 5 ) ) ; System . Console . WriteLine ( stirlingFactorial ( 6 ) ) ; System . Console . WriteLine ( stirlingFactorial ( 7 ) ) ; } }