> 其他 >
求VB编程代码(For循环).题目:求Fibonacci数列:1,1,2,3,5,8,…的前40个数
即:F1=1 (n=1), F2=l (n=2),Fn=F(n-l) F(n-2) (n>=3)谢谢
人气:239 ℃ 时间:2020-03-22 03:25:15
解答
Private Sub Form_Click()Dim a(1 To 40) As LongFor i = 1 To 40If i = 1 Or i = 2 Thena(i) = 1Elsea(i) = a(i - 2) + a(i - 1)End IfPrint a(i); Tab;If i Mod 5 = 0 Then PrintNext iEnd Sub
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版