Prime Number series in vb.net with source code .
in this program i have shown how to write program for
prime number in vb.net using for loop and if .
it is very simple to find out single prime number but when we comes across prime number
series then its challenge.
in this program i will tell you how to get prime number from 1 to 10 or 1 to n with comments.
just stick with this code later on i will show execution line by line by video
Public Sub Primenumber()
Response.Write("Prime number ")
Dim takeval As Integer
Dim flag As Integer
flag = 0
takeval = txtVal.Text
Dim i As Integer
Dim j As Integer
For i = 2 To takeval
For j = 2 To (i - 1)
If i Mod j = 0 Then
flag = 0
Exit For
Else
flag = 1
'Exit For
End If
Next j
If flag = 1 The
Response.Write(i)
Response.Write("</br>")
End If
Next i
End Sub
3 5 7 'will show prime number between 1 to 10.
you can call primenumber function on button click event also.
in this program i have shown how to write program for
prime number in vb.net using for loop and if .
it is very simple to find out single prime number but when we comes across prime number
series then its challenge.
in this program i will tell you how to get prime number from 1 to 10 or 1 to n with comments.
just stick with this code later on i will show execution line by line by video
Public Sub Primenumber()
Response.Write("Prime number ")
Dim takeval As Integer
Dim flag As Integer
flag = 0
takeval = txtVal.Text
Dim i As Integer
Dim j As Integer
For i = 2 To takeval
For j = 2 To (i - 1)
If i Mod j = 0 Then
flag = 0
Exit For
Else
flag = 1
'Exit For
End If
Next j
If flag = 1 The
Response.Write(i)
Response.Write("</br>")
End If
Next i
End Sub
3 5 7 'will show prime number between 1 to 10.
you can call primenumber function on button click event also.
0 comments: