DESCRIPTION:
Highest Number Prime Or not & up to Second Highest Number calculate Fibonacci series
PROPERTIES:
CODEING:
Highest Number Prime Or not & up to Second Highest Number calculate Fibonacci series
PROPERTIES:
Label1 | |
Text | (Empty) |
Label2 | |
Text | (Empty) |
Button1 | |
Text | Enter Number in Box |
Public Class Form1
Dim i As Integer = 1
Dim k As Integer = 1
Dim f_high, s_high As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If i <= 5 Then
If NumericUpDown1.Value > f_high Then
s_high = f_high
f_high = NumericUpDown1.Value
ElseIf NumericUpDown1.Value > s_high And Not NumericUpDown1.Value = f_high Then
s_high = NumericUpDown1.Value
End If
i += 1
Button1.Text = "Enter " & i & " Number"
End If
If i = 6 Then
Label1.Text = "Fibonacci series Up To " & s_high
i = 0
While i <= s_high
If k <= s_high Then
Label2.Text = Label2.Text & " " & i & " " & k
Else
Label2.Text = Label2.Text & " " & i
End If
i = i + k
k = i + k
End While
i = 2
k = 0
While i <= f_high / 2 And k = 0
If f_high Mod i = 0 Then
k = 1
else
i = i + 1
End If
End While
If k = 0 Then
MsgBox(f_high & " is Prime Number")
Else
MsgBox(f_high & " is not Prime Number")
End If
End If
End Sub
End Class
DESIGNING:Dim i As Integer = 1
Dim k As Integer = 1
Dim f_high, s_high As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If i <= 5 Then
If NumericUpDown1.Value > f_high Then
s_high = f_high
f_high = NumericUpDown1.Value
ElseIf NumericUpDown1.Value > s_high And Not NumericUpDown1.Value = f_high Then
s_high = NumericUpDown1.Value
End If
i += 1
Button1.Text = "Enter " & i & " Number"
End If
If i = 6 Then
Label1.Text = "Fibonacci series Up To " & s_high
i = 0
While i <= s_high
If k <= s_high Then
Label2.Text = Label2.Text & " " & i & " " & k
Else
Label2.Text = Label2.Text & " " & i
End If
i = i + k
k = i + k
End While
i = 2
k = 0
While i <= f_high / 2 And k = 0
If f_high Mod i = 0 Then
k = 1
else
i = i + 1
End If
End While
If k = 0 Then
MsgBox(f_high & " is Prime Number")
Else
MsgBox(f_high & " is not Prime Number")
End If
End If
End Sub
End Class
Comments
Post a Comment