[.NET] VB 2008 計算Exponential Function的程式寫法
我要寫一個可以計算exponential function的程式,
exponential公式是:e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + …
以下是我寫的程式,
我知道錯誤的地方應該蠻多的,
但是我不知道從何改起@@,
拜託各位大大幫幫忙!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, number_of_terms, i, n As Integer
Dim result, factorial As Double
x = TextBox1.Text
number_of_terms = TextBox2.Text
n = number_of_terms
If RadioButton1.Checked Then
factorial = 1
For i = 1 To n
factorial = factorial * i
Next
result = x ^ (n - 1) / factorial
Label4.Text = result
End If
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.240.186.200
推
11/02 13:09, , 1F
11/02 13:09, 1F
→
11/02 15:18, , 2F
11/02 15:18, 2F
→
11/02 15:18, , 3F
11/02 15:18, 3F
→
11/02 15:19, , 4F
11/02 15:19, 4F
→
11/02 21:09, , 5F
11/02 21:09, 5F
→
11/02 21:10, , 6F
11/02 21:10, 6F
→
11/02 21:18, , 7F
11/02 21:18, 7F
→
11/02 23:37, , 8F
11/02 23:37, 8F
→
11/02 23:41, , 9F
11/02 23:41, 9F