LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default fibbonacci series, with time function

What would I code to get a counter to tell me how many iterations
that it takes to get to my upper limit?


Oh...I see the math now. Because we don't know if the solution is Odd
or Even, the inverse most likely goes complex. However, if we take the
average, we stay within limits. You may note that the denominator is
the Log of the GoldenRatio.

Function MaxFibonacci(n)
MaxFibonacci = Int(Log(n * Sqr(5)) / Log((1 + Sqr(5)) / 2))
End Function

Sub TestIt()
Debug.Print MaxFibonacci(6000000000#)
End Sub

Returns: 48

This is the correct answer to your question because...

Fibonacci(48)
4,807,526,976

is the upper limit, and the next one exceeds your input number.

Fibonacci(49)
7,778,742,049

- - -
HTH :)
Dana DeLouis



Dana DeLouis wrote:
SteveDB1 wrote:
I just thought of something that might tell me part of what I want.
What would I code to get a counter to tell me how many iterations that
it takes to get to my upper limit?



For a looping solution, one way if we use your code...

Sub fibbonacci()
Dim i As Double
Dim j As Double
Dim N As Double
Dim fib As Double
Dim C As Double 'Counter

i = -1
j = 1
C = -1
While (fib <= 6000000000#)
C = C + 1
fib = i + j
i = j
j = fib
Wend
'We've exceeded our number
MsgBox "The Max Fibbonacci # is: " & C - 1
End Sub

- -
HTH
Dana DeLouis














"Dana DeLouis" wrote:

no problems....until I reach 1.84 billion.

Hi. If you change your Dim statements to Double, you will be able to
calculate a Fibbonacci number a little greater than 46.

I'm afraid I don't understand your question about Offset.

- - -
Dana DeLouis



SteveDB1 wrote:
Howdie all.
I've used some C# code to create my own fibbnoacci series macro.
-----------------------------------------------------------
Sub fibbonacci()
Dim i As Long
Dim j As Long
Dim N As Long
Dim fib As Long

i = -1
j = 1

While (fib <= 6000000000#)
fib = i + j
i = j
j = fib

Wend
MsgBox "The Fibbonacci # for this series is: " & fib
End Sub
-------------------------------------------------------------------
It works good, with no problems. Well, at least until I reach 1.84
billion.
What I want to do is to add a "time" function with a 9 month
limiter. I.e., each iteration has an output with each 9 months of
time, and a 13 to 17 year start point for each subsequent iteration
set. E.g.,
the fibbonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21,.......
So, my first set where 1 and 1 become 2, is at time = 9 months.
my next set where 2 becomes 3 is at least 9 months, and each
subsequent 9 months ++
I then want to do an offshoot from that, essentially starting over
with each 13 to 17 years.
My overall goal is a population growth analysis for personal
purposes. Back when I was taking my math classes, one of my
professors told me that the fibbonacci series was developed to
analyze rabbit population growth.
I realize that this might be over the top of what is done here, but
I wanted to at least ask. So, if it is, please let me know.
Thank you for your helps.
Best,
SteveB.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Series and Creating data points within a series Cristal Excel Discussion (Misc queries) 2 November 30th 09 08:07 PM
Lookup function with condition in time series data Tomas Excel Worksheet Functions 0 June 21st 06 06:33 PM
Time Series carl Charts and Charting in Excel 1 February 1st 06 04:18 PM
Time series mohitmahajan Excel Discussion (Misc queries) 8 December 14th 05 07:10 AM
prehistoric time series Folke Günther Excel Worksheet Functions 3 April 21st 05 02:18 PM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"