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:
Public Function GetFibonacciSequence(lnInput As Long) As Long
Dim Fib0 As Long
Dim Fib1 As Long
Dim Sum As Long
Dim n As Long
Fib 0 = 0
Fib 1 = 1
For n = 1 to lnInput
Sum = Fib0 + Fib1
Fib0 =Fib1
Fib1 = Sum
Next
GetFibonacciSequence = Fib0
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!
Bookmarks