I am assuming you are new to programming. In the code i
never refers to the array fib
. What is happening is that the for
loop is iterating the inner instructions n-2 times, and the inner instruction is written in such a way that in never needs to be pointed by i
. The loop inside always adds the last 2 numbers of the fib
array and appends in fib
array.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…