Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

visual basic program for fIBONACCI numbers? 1

Status
Not open for further replies.

grierfield

Technical User
Dec 18, 2002
55
US
does anyone have a VB program module for fIBONACCI numbers?

thanks
 



grierfield,

Welcome to Tek-Tips.

does anyone have a VB program module for fIBONACCI numbers?
That's not how it works, here at Tek-Tips. These are forums for professionals, who are experiencing problems with their tasks.

Your question seems like it might be a school assignment.

Can you explain?

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
no it is not - that request was just for personal Aggrandizement for a senior citizen
 



I'm with ya pops -- 67!!! If you're younger than me, yer just a kid!

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
You guys are the best – thanks – it makes my day
 
I made one up just for fun using Excel.
Here is what I came up with.
It just calculates the numbers in the series up to the limit you enter.

Code:
Sub Fibonacci()

Dim Fn() As Single 'Type Long required for a limit greater than 183

limit = 20 'Enter the series calculation limit here.
ReDim Fn(0 To limit) 'Size the array for the series limit

Fn(0) = 0 'Always 0
Fn(1) = 1 'Always 1

Fna = 0
Fnb = 1
Fnc = 0
Fnx = 0

'The first two numbers of the series are always 0 and 1
'the next number is then the sum of preceding two numbers
For x = 2 To limit
    Fnx = Fna + Fnb
    Fnc = Fnb
    Fnb = Fnx
    Fna = Fnc
    Fn(x) = Fnx
    
Debug.Print x, Fn(x)'Prints Fn(2)... Fn(limit)

Next

Erase Fn() 'Clears the memory when finished.

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top