import time import sys def primes(n): global no_div if n < 2: return 0 if n==2: return 1 if not n & 1:# all other even numbers are not primes return 0 x=3 while(x<=n**0.5): no_div=no_div+1 if n % x == 0: return 0 x=x+2 return 1 f=open('in2_51.txt','r') n=int(f.readline()) f.close() f1=open('out_15_2_5.txt','w') t1=time.clock() m=2 a=1 b=1 p=1 no_div=0 no_add=0 while(p<=n): m=m+1 c=a+b no_add=no_add+1 a=b b=c f=primes(c) if(f==1): f1.write(str(m)) print m f1.write(",") p=p+1 t2=time.clock() t=t2-t1 mem=sys.getsizeof(a)+sys.getsizeof(b)+sys.getsizeof(c)+sys.getsizeof(no_div)+sys.getsizeof(no_add)+sys.getsizeof(m)+sys.getsizeof(p)+sys.getsizeof(f) f1.write("\nno of additions=%d\nno.of multiplications=0\nno.of divisions=%d\ntime taken=%fseconds\nmemory used=%d bytes"%(no_add,no_div,t,mem)) f1.close()