07-09-2023, 05:00 AM
Here is the function converted to QB64 using an unsigned _INTEGER64. Of course it breaks down at the upper limit of _INTEGER64. Interesting coding challenge. Thoughts anyone?
Code: (Select All)
FOR i = 1 TO 100
_LIMIT 10
PRINT fibIter(i)
NEXT i
FUNCTION fibIter~&& (n)
IF n < 2 THEN
fibIter = n
ELSE
fibPrev = 1
fib = 1
FOR i = 2 TO n - 1
fibPrevTemp = fib
fib = fib + fibPrev
fibPrev = fibPrevTemp
NEXT i
fibIter = fib
END IF
END FUNCTION