2008年5月16日 星期五

質數


自行定義你們要的變數…
千萬不要一樣啊
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j, s, thend As Integer
Dim flag As Boolean
Dim output As String = ""

s = CInt(txts.Text)
thend = CInt(txte.Text)

For i = s To thend
flag = True
For j = 2 To i - 1

If i Mod j = 0 Then
flag = False
End If
Next j
If flag = True Then
output = output & i & " "
End If
Next i

txtoutput.Text = output

End Sub
End Class

沒有留言: