Fibonacci Sequence calculation

noosaj

Member
Joined
Mar 5, 2007
Messages
6
Programming Experience
Beginner
Hello,

First off, I know there are many code snippets out there that show how to calculate a Fibonacci number. What I need to do is the opposite. I am a student at Indiana Univ. and am struggling with this. All I'm asking is simply for help and suggestions. It will be much appreciated.

Here's what I have: I have a numeric up and down control that displays the numbers 3 to 50. When the user selects a number, and clicks on the Compute button, I need a messagebox that shows the Fibonacci number.

For example, if the user selects the number '6', then I should have a messagebox appear with the Fibonacci number 8, because 8 is the 6th integer in the sequence.

I am struggling with how to write code for this. Please bear with me as I am still new to VB.NET and am still learning.

Thanks for any and all advice you can give.

Jason
 
Declare an array of size 50, (0 to 49)
Into it calculate the fibonacci sequence, using a loop.
-->Populate the first two elements with 1 then use a loop to do the rest
-->remember that the algorithm for any location(N) is location(N-1) plus location(N-2)
When the user picks a number, show the array location related to that number (remeber that your user will pick up to 50, but your array runs up to 49, a simple calc is needed --> when the user picks 6, you need to show location 5 etc)
 
ps; take my post, put apostrophes before all the lines to make them into vb comments
insert the comments into the code
THEN write the code to match the comments


This is how all programmers (should) do their complex algorithms.. in English (or whatever your native language) first, then VB (a foreign language)
 
Back
Top