斯特林公式求阶乘

  

 

[1]

  或更精确的

  

 

下面是分别用vb.net编写的普通的方式和上面这个近似计算的方式计算出来的结果

Imports System.Math

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim n As Double = TextBox1.Text
        Dim result As Double = 1
        For i As Double = n To 2 Step -1
            result = result * i
        Next
        TextBox2.Text = result.ToString
        Const pai As Double = 3.14159265358
        Const ee As Double = 2.718281828459
        TextBox3.Text = Sqrt(2 * pai) * (n ^ (n + 1 / 2)) * (ee ^ (-n))




    End Sub
End Class

 
斯特林公式求阶乘
 

你可能感兴趣的:(阶乘)