用vb輸出斐波那契數列前20項的所有偶數

時間 2021-12-22 23:34:25

1樓:銷聲匿跡

private sub form_click()dim d(100000), i as longd(0) = 0

d(1) = 1

for i = 2 to 20

d(i) = d(i - 1) + d(i - 2)next i

for i = 0 to 20

print d(i) & space(5);

if i mod 5 = 0 then printnext i

print "偶數"

for i = 0 to 20

if d(i) mod 2 = 0 then print d(i);

next i

end sub

2樓:匿名使用者

你要vb6還是vb.net?

vb求出斐波那契數列的前20項,並按順序將他們顯示在列表框中。

3樓:匿名使用者

單擊窗體後在窗體上輸出前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 printprint f(i);

next i

end sub

稍改一下吧

用子過程輸出fibonacci數列的前20項及前20項和(vb) 5

4樓:

1.( s )= a + b

2.print ( c )

vb程式設計題,列印fibonacci數列的前20項。該數列的第一項為0,第二項為1,從第三項開始,每

5樓:旅初彤

不對吧,fibonacci數列前面兩項都是1哦

vb中輸出斐波那契數列的前20項

介面加乙個按鈕,直接複製執行 private sub command1 click dim a 1 to 20 as integerfor i 1 to 20 if i 1 or i 2 thena i 1 else a i a i 1 a i 2 end if print i,a i next i...

斐波那契數列求和,斐波那契數列求和程式怎麼編寫?

1 fig.6.30 fig06 30.cpp 2 testing the recursive fibonacci function.3 include 4 using std cout 5 using std cin 6 using std endl 78 unsigned long fibona...

斐波那契數列前20項求和,斐波那契數列前20項求和pascal

program gxd varf1,f2,tot,i,tmp longint begin f1 1 f2 1 tot 2 for i 3 to 20 do begin tmp f1 f2 inc tot,tmp f1 f2 f2 tmp end writeln tot readln end.peog...

斐波那契數列什麼時候會學,斐波那契的斐波那契數列是什麼時候提出的

斐波那契數列的發明者,是義大利數學家列昂納多 斐波那契 leonardo fibonacci 生於公元1170年,卒於1250年,籍貫是比薩。他被人稱作 比薩的列昂納多 1202年,他撰寫了 算盤全書 liber abacci 一書時提出的 斐波那契數列和花瓣的聯絡什麼 時間發現的 這裡對斐波那契數...

Pascal神秘數列,pascal斐波那契數列

陣列a 1.n 儲存數列,在設乙個b 1.n 的陣列,其中儲存的數為1或 1,只有b 1 永遠為1 窮舉所有b 1.n 可能情況,寫個求和函式sum,sum n a n b n sum n 1 且sum 1 a 1 如果sum n 與目標數相同,那麼從頭掃瞄陣列b,如果b x 1,那麼求e x 直到...