I have the following code where I break the for loop if the IF condition is met.
def fib_huge(n, m):
a=[0,1]
for i in range(2,(m*m)):
a.append((a[i-1] + a[i-2])%m)
if a[i] == 0 and a[i-1]==1:
print(a)
break
print("a[8]=",a)
print(i)
r = n % (i-2)
print("r=",r)
in the if condition if I give input if a[i] == 1 and a[i-1]==0 it works but if i change it to if a[i] == 0 and a[i-1]==1 it doesnt work. The If statement is run on this array a = [0 1 1 2 0 2 2 1 0 1 1](i goes upto 10)
if I use a[i] == 1 and a[i-1] == 0 the loop correctly terminates at a[8] so the sequence is a = [0 1 1 2 0 2 2 1 0]
if however i use a[i]==0 and a [i-1] == 1 the loop should terminate at a[9] but it still terminates at a[8] and we get the same o/p.
Can somebody point out what mistake I am making?
