Prime Numbers between 1 - 100

Option Explicit

Private Sub cmdDisplay_Click()
Dim n As Integer
Dim i As Integer
Dim p As Byte
p = 1
For n = 2 To 100
For i = 2 To n \ 2
If n Mod i = 0 Then
p = 0
Exit For
Else
p = 1
End If
Next
If p = 1 Then
Print n
End If
Next
End    Sub

No comments:

Post a Comment

Note: only a member of this blog may post a comment.