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

如題,小弟我自己寫了一下,發現跑不出來,忙煩哪位大大可以幫忙修正,謝謝~
Function numprime(n)
If I < 1 Then
numprime = x
Else
n = I
End If
k = 0
For L = 2 To I
For J = 2 To L
If J <> L Then

If (L Mod J) = 0 Then
z = True

If (L Mod J) <> 0 Then
z = False
End If
End If
End If
Next J
If z = True Then
k = k
If z = False Then
k = k + 1
End If
End If
Next L
numprime = k
End Function

2006-03-18 12:23:10 · 2 個解答 · 發問者 ...掛...了... 1 in 電腦與網際網路 程式設計

抱歉,第一行是n

2006-03-18 12:26:54 · update #1

2 個解答

Function numprime(n)If n < 1 Then   Exit FunctionElse   I = nEnd IfFor L = 2 To I    For J = 2 To L - 1        If L Mod J = 0 Then           z = True           Exit For        Else           z = False        End If    Next J    If z = False Then       k = k + 1    End IfNext Lnumprime = kEnd Function

2006-03-18 22:23:13 補充:
少了個z=false,真是誤人子弟For L = 2 To I  z = False '請加在此  For J = 2 To L - 1

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

to:W.J.S.
都已經是「研究生 3 級」了,還不懂得使用「HTML 精靈」嗎?
利用「HTML 精靈」效果會比較好喔!

2006-03-18 17:34:56 · answer #2 · answered by 世賢 7 · 0 0

fedest.com, questions and answers