"""calculate the the prime factors of the no""" import time import sys t0=time.clock() def fac(n): if n==0: t3=0 print t3 div=0 else: for i in range(2,n+1): div=0 f=0 for j in range(2,i/2+1): div=div+1 if i%j==0: f=f+1 j=j+1 if f==0: div=div+1 while n%i==0: div=div+1 if n%i==0: n=n/i c=i w.write(repr(c)+ ",") i=i+1 w.write("\n") return div """Taking the input from file and producing the result""" f=open("c:\inputs\in3_6.txt",'r') w=open("out_16_sec3_6.txt","w") a1=f.readline() b1=int(a1) print"no of terms" print b1 divisions=0 str=f.readlines() for i in range(len(str)): a=str[i] b=a.split(',') for x in range(b1): t=b[x] print t g=int(t) divi=fac(g) divisions=divisions+divi w.write("no of divisions:=") w.write(repr(divisions)+"\n") mem=sys.getsizeof(a1)+sys.getsizeof(b1)+sys.getsizeof(a)+sys.getsizeof(b)+sys.getsizeof(str)+168 t1=time.clock() t2=t1-t0 w.write("time taken=") w.write(repr(t2)+"\n") w.write("memory used=") w.write(repr(mem)) w.close()