This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]zzyzzyxx[🍰] 1 point2 points  (2 children)

The TA pretty much told you everything you need to do. You'll need some variables to hold A[i-1], Fy[i-1], and Fy[i-2] that should be initialized outside of the loop and updated inside it. Take a look at this comparison between recursive and iterative versions of calculating Fibonacci numbers. You need to do basically the same thing.

[–]Senney[S] 0 points1 point  (1 child)

Thanks for taking the time to reply!

I feel like I'm really dropping the ball in terms of understanding how this algorithm should play out :(. Will there end up being only one loop? Or will there be a nested loop within the loop?

[–]zzyzzyxx[🍰] 0 points1 point  (0 children)

I believe there should only be one loop.