import sys import time def fibo(): start=time.clock() f=open("in2_8.txt","r") f1=open("out_28_2_8.txt","w") temp=[] for x in f: for y in x.split(','): y=y.strip() temp.append(y) g=int(temp[0])+1 t=[] add=0 mul=0 for p in range(1,g): n=int(temp[p]) n1=((5*n**2)+4) n2=((5*n**2)-4) add+=2 mul+=4 m1=n1**.5 m2=n2**.5 if (m1%1==0): t.append("1") elif (m2%1==0): t.append("1") else: t.append("0") f1.write(','.join(t)) tc=time.clock()-start total=sys.getsizeof(t)+sys.getsizeof(n)+sys.getsizeof(n1)+sys.getsizeof(n2)+sys.getsizeof(m1)+sys.getsizeof(m2) f1.write("\nAdditions : "+str(add)+"\nMultiplications : "+str(mul)+"\nTime :"+str(tc)+"\nMemory :"+str(total)) f.close() f1.close() fibo()