有一分数序列2/1,3/2,5/3,8/5 .,求这个数列前20 项之和 计算机VB编程,
问题描述:
有一分数序列2/1,3/2,5/3,8/5 .,求这个数列前20 项之和 计算机VB编程,
答
Private Sub Command1_Click()
Dim a As Long, b As Long, c
Dim i As Integer, sum As Single
a = 2
b = 1
For i = 1 To 20
sum = sum + a / b
Print i; a; "/"; b
c = a
a = a + b
b = c
Next
Print
Print
Print sum
End Sub