Prime Number
Verification
iNumber = CInt(InputBox("Please enter the number"))
iCount = 0
For i=1 To iNumber
If iNumber Mod i = 0 Then
iCount = iCount+1
End If
Next
If iCount = 2 Then
MsgBox "Given Number is a Prime Number"
Else
MsgBox "Given Number is NOT a Prime Number"
End If
iCount = 0
For i=1 To iNumber
If iNumber Mod i = 0 Then
iCount = iCount+1
End If
Next
If iCount = 2 Then
MsgBox "Given Number is a Prime Number"
Else
MsgBox "Given Number is NOT a Prime Number"
End If
Prime Numbers Generation
iRange = CInt(InputBox("Please enter the range"))
For i=1 To iRange
iCount = 0
For j=1 To i
If i Mod j = 0 Then
iCount = iCount+1
End If
Next
If iCount = 2 Then
iPrimes = iPrimes & " " & i
End If
Next
MsgBox "Prime Numbers in the given range " & iRange & " are: " & iPrimes
iCount = 0
For j=1 To i
If i Mod j = 0 Then
iCount = iCount+1
End If
Next
If iCount = 2 Then
iPrimes = iPrimes & " " & i
End If
Next
MsgBox "Prime Numbers in the given range " & iRange & " are: " & iPrimes
No comments:
Post a Comment