944,131 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 6372
  • VB.NET RSS
Nov 17th, 2005
0

Help,Fibonacci numbers

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lefraso is offline Offline
1 posts
since Nov 2005
Dec 2nd, 2005
0

Re: Help,Fibonacci numbers

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Danny.VBT is offline Offline
8 posts
since Aug 2005
Jul 11th, 2010
0
Re: Help,Fibonacci numbers
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
t365247 is offline Offline
1 posts
since Jul 2010
Jul 15th, 2010
0
Re: Help,Fibonacci numbers
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.
Last edited by mnmw; Jul 15th, 2010 at 1:29 pm.
Reputation Points: 3
Solved Threads: 1
Light Poster
mnmw is offline Offline
26 posts
since May 2008
Jul 15th, 2010
0
Re: Help,Fibonacci numbers
Click to Expand / Collapse  Quote originally posted by t365247 ...
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
Reputation Points: 3
Solved Threads: 1
Light Poster
mnmw is offline Offline
26 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: ENTER keypress event only handled once
Next Thread in VB.NET Forum Timeline: Clear textbox from Listview selection





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC