program to
check the number is prime or not.
-----------------------------------------code---------------------------------------------------------
Public Class Form1
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button1.Click
Dim n,
i, c As Integer
n = TextBox1.Text
For i =
1 To n
If
(n Mod i = 0) Then
c = c + 1
End
If
Next i
If (c
> 2) Then
MsgBox("Number
is not prime", , "Message")
TextBox1.Text = ""
Else
MsgBox("Number
is prime", , "Message")
TextBox1.Text = ""
End If
End Sub
End Class
-----------------------------------------output----------------------------------------------------
codestrew |
codestrew |
No comments:
Post a Comment