import time import sys f=open('in6_5.txt','r') for sh in f: l=sh.split(",") rate= int(l[0]) princi=int(l[1]) tme=int(l[2]) f.close() f1=open('out_15_6_5.txt','w') no_mul=0 def pow(x,y): global no_mul if(y==0): return 1 temp=pow(x,y/2) if(y%2==0): no_mul=no_mul+1 return temp*temp else: if(y>0): no_mul=no_mul+2 return x*temp*temp else: no_mul=no_mul+1 return (temp*temp)/x t1=time.clock() amount=princi*pow(1+rate/100.0,tme) rate=amount-princi t2=time.clock() t=t2-t1 mem=sys.getsizeof(amount)+sys.getsizeof(rate)+sys.getsizeof(princi)+sys.getsizeof(tme)+sys.getsizeof(no_mul) f1.write(str(rate)) f1.write('\nno. of multiplications=%d\nno.of additions=0\ntime taken=%f\nmemory used=%d'%(no_mul,t,mem)) f1.close()