import sys import time def fib(): global mem f=open("in2_5.txt","r") w=open("out_5_2_5.txt","w") n=int(f.read()) f.close() a=1 b=1 z=2 g=1 global addcount while g<=n: z=z+1 addcount+=1 c=a+b a=b b=c f=prime(c) if(f==1): w.write(str(z)+",") g=g+1 mem+=sys.getsizeof(f)+sys.getsizeof(w)+sys.getsizeof(n)+sys.getsizeof(a)+sys.getsizeof(g)+sys.getsizeof(z)+sys.getsizeof(b)+sys.getsizeof(c) def prime(n): global mem global divcount y=int(n**0.5) for j in range (2,y+1,1): a = n%j divcount+=1 if (a==0): return 0 mem+=sys.getsizeof(y)+sys.getsizeof(n) return 1 st=time.clock() mem=0 addcount=0 divcount=0 mulcount=0 fib() end=time.clock() t=end-st w=open("out_5_sec2_5te.txt","a") w.write("\nTotal Time: " +str(t)) mem+=sys.getsizeof(st)+sys.getsizeof(end) w.write("\nMemory used: " +str(mem)) w.write("\nAdditions "+str (addcount)) w.write("\nDivision "+str(divcount)) w.write("\nMultiplication "+str(mulcount)) w.close()