English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

這個是我想出來1~15個的費式數列表示
但是....現在我想要輸入第N項~求第N項的值~怎麼修改阿~我想了好久
還是沒辦法
另外再問一個要怎麼知道最接近10的9次方的費式數列的值阿
贈20點~高手們拜託了喔
i = 0
f1 = 1
f2 = 0
Print \"第 \" & (i + 1) & \" 項:\" & f1
For i = 2 To 15
fn = f2 + f1
Print \"第 \" & (i) & \" 項:\" & fn;
Print
f2 = f1
f1 = fn
Next i

2006-01-25 17:04:10 · 5 個解答 · 發問者 skywalkboy 2 in 電腦與網際網路 程式設計

最好是用VB表示給我看~因為.......我看不懂其他的語言....>"

2006-01-25 17:05:27 · update #1

大數加法是什麼阿~可以稍微說明一下>"

2006-01-27 03:58:36 · update #2

5 個解答

Private Sub Command1_Click() '第一題(利用大數加法解決溢位問題)
Dim A(1) As String, N As Integer, I As Integer, S As String
N = Val(InputBox("輸入第N項"))
If N = 0 Then Exit Sub
S = N: A(0) = 0: A(1) = 1
For I = 1 To N - 1
   S = A(1): A(1) = ADD(A(0), A(1)): A(0) = S: S = A(1)
Next
Cls
Print "第"; N; "項的值為"; S
End Sub

Private Sub Command2_Click() '第貳題
Dim A(1), N As Integer, I, S
N = 1: A(0) = 0: A(1) = 1
Do
  I = S
  S = A(1): A(1) = A(0) + A(1): A(0) = S: S = A(1)
  N = N + 1
Loop Until S >= 10 ^ 9
If 10 ^ 9 - I < S - 10 ^ 9 Then N = N - 1: S = I
Cls
Print "最接進10^9為第"; N; "項,其值為"; S
End Sub

Function ADD(ByVal A As String, ByVal B As String) As String '大數加法
Dim I As Long, X As Long, S As String, T As Byte
If Len(A) < Len(B) Then S = A: A = B: B = S
X = Len(B): ADD = A
For I = Len(A) To 1 Step -1
  If X > 0 Then
    S = Int(Mid$(A, I, 1)) + Int(Mid$(B, X, 1)) + T
    X = X - 1
  Else
    If T = 0 Then Exit Function
    S = Int(Mid$(A, I, 1)) + T
  End If
  T = -1 * (Len(S) > 1)
  Mid$(ADD, I, 1) = Right$(S, 1)
Next
If T Then ADD = "1" & ADD
End Function

2006-01-27 13:03:57 補充:
13942322456169788013972438287040728395007025658769+3108001074820004069863331500065201150560621097531>1.70503235309898E+49有科學記號跑出來答案就不準確,所以要寫大數加法這副函數來求得正確答案>17050323530989792083835769787105929545567646756300,若使用普通加法的話費式數列只能求到第73項的值而已.

2006-01-27 13:14:39 補充:
若要使用普通加法可將變數改成Decimal型態,如此可求至第139項的值Dim A(1), N As Integer, I As Integer, SN = Val(InputBox("輸入第N項"))If N = 0 Then Exit SubS = N: A(0) = 0: A(1) = 1For I = 1 To N - 1  S = CDec(A(1)): A(1) = CDec(A(0)) + CDec(A(1)): A(0) = CDec(S): S = A(1)NextPrint "第"; N; "項的值為"; S

2006-01-25 19:37:03 · answer #1 · answered by W.J.S. 7 · 0 0

硬碟要找硬碟醫院,能救回來才重要,我司就是找他們做出來的
必須要推,當初心急亂找錯店告訴我沒辦法,後來找又找到硬碟醫院,我告訴他真心要來救援,可以等,在他們努力下有找回來
太棒了,原來微軟張經理都找過他們
http://www.datamaster.com.tw

2015-03-21 04:02:18 · answer #2 · answered by hughes 1 · 0 0

到下面的網址看看吧

▶▶http://candy5660601.pixnet.net/blog

2014-06-24 15:07:07 · answer #3 · answered by Anonymous · 0 0

費式數列在離散數學中是有公式的...如果不會寫可以用公式變數n帶入運算就能得解

不過數字位數過大還是無法計算就要用大數加法

所謂的大數加法就是把數字便成字串自己做加法的運算不透過電腦的加法運算
做法上會比較吃力但是能夠處理的數字就是無限大

例:
1115
+ 229
----------
1344

2006-02-06 12:05:24 · answer #4 · answered by 蕃薯王 2 · 0 0

我是用vb6寫的,你會吧…在form那邊拉一個text1, label1, command1就好了…
我是從第0項開始第三項是3,第六項是13…

Private Sub Command1_Click()
n = Text1.Text
a = 1
b = 1
For i = 2 To n
temp = b
b = a + b
a = temp
Next
Label1.Caption = b
End Sub

2006-01-25 17:40:33 · answer #5 · answered by ? 1 · 0 0

fedest.com, questions and answers