954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help,Fibonacci numbers

I would like to design a programm in visual basic.net meet the following requirements:

Fibonacci numbers Input limit is 15
Numbers are 0 1 1 2 3 5 8 13

The program must allow input limit
Display all generated Fibonacci numbers
The sum of all the Fibonnacci numbers

Anyone who can help me with this ,i will appreciate.

lefraso
Newbie Poster
1 post since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

I don't want to give you the exact answer but your going to need two temp variables to hold the last two numbers of the sequence, also another var to add each number. It's not a difficult application...the concept of temporary variables may be confusing at first.

Here's a few things off the top of my head that you'll need...

1.) Input Box
2.) Loop
3.) Temp. Variables
4.) Variable to act as a sum of fibonacci numbers.

Danny.VBT
Newbie Poster
8 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

I am having a similar problem. I am using visual basic express 2008 and running vista. I don't know if i am even in the ballpark because or all the bugs that occur whenever i try to run vb apps. can anyone help?


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As Integer
Dim y As Integer
Dim z As Integer


x = 1
y = 1

For count As Integer = 1 To 10

y = x
x = z
z = x + y
Label1.Text = (x + y).ToString _
& ControlChars.NewLine
count += 1
Next count



End Sub

t365247
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Well, you can solve this problem using two methods:
1. Iterative approach...like what you guys are trying
2. Recursive approach which to me is easier.....next term (N) in Fibonacci series is given by N = Fibonacci(N-1) - Fibonacci(N-2) where N > 0. Then you can loop any number of times to generate the different terms.

mnmw
Light Poster
26 posts since May 2008
Reputation Points: 3
Solved Threads: 1
 

I am having a similar problem. I am using visual basic express 2008 and running vista. I don't know if i am even in the ballpark because or all the bugs that occur whenever i try to run vb apps. can anyone help?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim x As Integer Dim y As Integer Dim z As Integer

x = 1 y = 1

For count As Integer = 1 To 10

y = x x = z z = x + y Label1.Text = (x + y).ToString _ & ControlChars.NewLine count += 1 Next count

End Sub

You only need to concatenate your label output. Also remember to clear label before you start looping:Label1.Text = ""
For count As Integer = 1 To 10

y = x
x = z
z = x + y
Label1.Text = Label1.Text + (x + y).ToString _
& ControlChars.NewLine
count += 1
Next count

mnmw
Light Poster
26 posts since May 2008
Reputation Points: 3
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You