Private Sub Form_Load()
Text1.Text = ""
s = 0: n = 1: f = 1
For n = 2 To 30
s = n * s + 2 * n - 1
f = f * n
Text1.Text = Text1.Text & Str(n) & Str(s / f) & Chr(13) & Chr(10)
Next
End Sub
finds
2 1.5
3 2.33333333333333
4 2.625
5 2.7
6 2.71527777777778
7 2.71785714285714
8 2.71822916666667
9 2.71827601410935
10 2.71828125
11 2.71828177609428
12 2.71828182411082
13 2.71828182812558
14 2.71828182843529
15 2.71828182845747
16 2.71828182845895
17 2.71828182845904
18 2.71828182845905
19 2.71828182845905
20 2.71828182845905
21 2.71828182845905
22 2.71828182845905
23 2.71828182845905
24 2.71828182845905
25 2.71828182845905
26 2.71828182845905
27 2.71828182845905
28 2.71828182845905
29 2.71828182845905
30 2.71828182845905
At n=18 S(n)/n! has reached the value of e to the accuracy of the double-precision numbers used in the program.
|
Posted by Charlie
on 2014-04-21 13:46:49 |