网络辞海>>vB中的斐波那契数列 前20项取值总和问题如题 谢谢了>>正文

vB中的斐波那契数列 前20项取值总和问题如题 谢谢了

斐波那契数列前三项分别是0、1、1,你只加了第二项或第三项 所以才会少1 Dim a&(20) a(1) = 0: a(2) = 1 For i = 3 To 20 a(i) = a(i - 2) + a(i - 1) b = a(i) + b Next i For i = 1 To 20 Print Right(Space(7) & a(i), 8); If i Mod 10 = 0 T...

Dim st As String = "" Dim a(100) a(1) = 0 : a(2) = 1 For i = 3 To 100 a(i) = a(i - 2) + a(i - 1) Next i For i = 1 To 100 st = st & a(i) & " " If i Mod 10 = 0 Then st = st & vbCrLf Next i TextBox6.Text = st

单击窗体后在窗体上输出前20个斐波那契数(5个一行) Private Sub Frm_click() Dim f(20) as integer F(1)=1 F(2)=1 For i=3 to 20 F(i)=f(i-2)+f(i-1) Next i For i=1 to 20 If i mod 5=0 then print Print f(i); Next i End Sub 稍改一下吧

不对吧,fibonacci数列前面两项都是1哦

'百度 tonkeys 原创Private Sub Command1_Click() Text1.Text = Fibonacci2(20) '调用函数返回前20项Fibonacci数的偶数,在文件框中输出结果End Sub'返回前N项Fibonacci数的偶数Public Function Fibonacci2(N As Integer) As String Dim a As Int...

Private Sub Command1_Click() a = 1 b = 1 print a;b For i = 3 To 20 c = a + b a = b b = c Print c-b Next End Sub 我也是刚学几天 用for编了一个 嘿嘿 互相讨论497760237 我QQ

斐波那契数列的发明者,是意大利数学家列昂纳多·斐波那契. 斐波那契数列指的是这样一个数列:1、1、2、3、5、8、13、21、…… 下面是前1000项斐波那契数列的和的VB代码: Private Sub Command1_Click() Dim a As Integer Dim b As Integer Dim c As...

Private Sub Command1_Click() Dim a As Integer, b() As Double, i As Integer Text1.Text = "" a = Val(Text2.Text) ReDim b(a) If a >= 2 Then b(1) = 0 b(2) = 1 For i = 3 To a b(i) = b(i - 1) + b(i - 2) Next i End If For i = 1 To a T...

#include void main() { int a[21]; a[0]=0; a[1]=1; for(int i=2;i

Private Sub Command1_Click() Dim a(1 To 50) As Integer For i = 1 To 50 If i = 1 Or i = 2 Then a(i) = 1 Else a(i) = a(i - 1) + a(i - 2) End If Print i, a(i) Next i End Sub