import sys from time import clock try: input=open('c:\inputs\in3_6.txt','r') output=open('out_26_sec3_6.txt','w') except IOError: print "The file does not exist" memory=0 start=clock() count=0 div=0 memory=memory+sys.getsizeof(count)+sys.getsizeof(div) for row in input: if count==0: l=int(row) memory=memory+sys.getsizeof(l) else: list=row.split(",") memory=memory+sys.getsizeof(list) count=count+1 for i in range(len(list)): count=0 while int(list[i])!=1: for j in range(2,int(list[i])+1): if int(list[i])%j==0: list[i]=int(list[i])/j count=count+1 div=div+2 start=clock()-start if count==1: output.write(str(j)) else : output.write(","+str(j)) break output.write("\n") memory=memory+sys.getsizeof(i)+sys.getsizeof(j) start=clock()-start output.write(" No ofdivisions are "+str(div)+"\n Time consumed is "+str(start)+" secs""\n Memory consumed is "+str(memory)+" bytes") input.close() output.close()