+ Reply to Thread
Results 1 to 6 of 6

Help with a Fibonacci function

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    USA
    MS-Off Ver
    2013
    Posts
    11

    Help with a Fibonacci function

    Hello everyone

    I have figured out how to write a program to produce the nth Fibonacci number, but now I want to figure out a way to find the sum of all odd Fibonacci numbers less than one million. This is my working Fibonacci program:
    Please Login or Register  to view this content.
    How can I rewrite this function to find the sum of all odd Fibonacci numbers less than one million? As long as I can print it out to the immediate window is all I really need. Any assistance is greatly appreciated. Thank you!
    Last edited by Leith Ross; 12-22-2014 at 07:50 PM. Reason: Added Code Tags

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Help with a Fibonacci function

    You have a problem -- your function will only generate up to the 46th Fibonacci number before it exceeds the allowable range of a Long. Fibonacci(1474) is about 5E307, close to the largest number a Double can store. There is no data type in VBA that could store the size of numbers the calculation would require; I think you would need to do string arithmetic.
    Last edited by shg; 12-22-2014 at 07:44 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-15-2014
    Location
    USA
    MS-Off Ver
    2013
    Posts
    11

    Re: Help with a Fibonacci function

    What if I were to use a constant input of 30 instead? Because anything above 30 returns a Fibonacci number > 1,000,000. If I do it that way, could the function be rewritten to sum all the odd Fibonacci numbers? And if so, how can it be done?

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Help with a Fibonacci function

    there are 31 or 30 nos < 1000000 depending on whether you use 0,0 or 0,1 as your starting point
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Help with a Fibonacci function

    I misread your question; I thought you meant to sum odd F numbers through the 1 millionth.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-15-2014
    Location
    USA
    MS-Off Ver
    2013
    Posts
    11

    Re: Help with a Fibonacci function

    Thank you for the help, shg, it really cleared things up for me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Fibonacci function/command in excel?...tia sal
    By JE McGimpsey in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 07:05 AM
  2. [SOLVED] Fibonacci function/command in excel?...tia sal
    By in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  3. [SOLVED] Fibonacci function/command in excel?...tia sal
    By in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  4. [SOLVED] Fibonacci function/command in excel?...tia sal
    By in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-05-2005, 11:05 PM
  5. [SOLVED] Fibonacci function/command in excel?...tia sal
    By in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-07-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1