For my application, i need the user to input a number, and the application will work out the highest possible Fibonacci number below the user inputed number.
At the moment, my application is providing non-Fibonacci numbers, which is a problem.
Here is the code:
Any help would be greatly appreciated. Thanks!
Haxaro
At the moment, my application is providing non-Fibonacci numbers, which is a problem.
Here is the code:
VB.NET:
Public Class Form1
Dim Input = Input1.Text
Dim output = Output1.Text
Private Sub Main(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Work.Click
' Declarations
Dim FirstNum = 1 'Declare
Dim OverFlow = 1 'Declare
Dim BackUp = 1 'Declare
Dim PreResult = 1 'Declare
Dim Result = 1 'Declare
Dim FinalResult = 1 'Declare
Do Until Result > Input() ' Loop until the result is greater than the user inputed text
FirstNum = BackUp ' Prepare for next loop
PreResult = Result + FirstNum ' Add X + Y = Z
BackUp = PreResult ' Prepare for next loop
Result = PreResult ' Prepare for next loop
Loop
If Result > Input() Then ' When the result is greater than the user inputed text, run:
FinalResult = Result - BackUp ' Go back one Fibonacci number
output = FinalResult ' Output the final Number lower than the user inputed text
End If
End Sub
End Class
Any help would be greatly appreciated. Thanks!
Haxaro