import sys import time t1=time.clock() count_mul=0 def factorial(n) : if n <= 1 : return 1 return n*factorial(n-1) product=1 factr = open("in1_10.txt") buff=factr.read() x=int(buff) for i in range(1, x+1): product *= factorial(i) count_mul=count_mul+i factw = file("out_20_1_10.txt",'w') print >>factw, product factw.write('\n total no of multiplications is'+" "+ str(count_mul)+ '\n') t2=time.clock() factw.write('time taken is'+" "+ str(t2-t1)+ '\n') factw.write('memory taken'+" "+ str(sys.getsizeof(factorial)+sys.getsizeof(product))+'\n') factw.close()