import sys import time f=open("c:\inputs\in3_9.txt","r") f1=open("out_9_sec3_9.txt","w") inputfile= int(f.readline()) start=time.clock() div=0 mul=0 num=2 remender=1 counter=0 product=1 while counter!=inputfile: ## LOOP WILL RUN TILL RANGE OF INPUT divident=2 while divident<=num/2: remender=num%divident ## LOGIC OF PRIME NO. div=div+2 ## CALCULATE THE NO. OF DIVISION if remender==0: break divident=divident+1 if remender!=0: product=product*num ##PRODUCT OF FIRST N PRIME NO. mul=mul+1 ## CALCULATE THE NO. OF MULTIPLICATION counter=counter+1 num=num+1 elapsed=(time.clock())-start ## CALCULATE TIME total=sys.getsizeof(product)+sys.getsizeof(elapsed)+sys.getsizeof(div)+sys.getsizeof(mul)+sys.getsizeof(counter)+sys.getsizeof(num)+sys.getsizeof(remender) f1.write("\n"+str("product of first n primes-:")+str(product)+"\n"+str("time---------------------:")+str(elapsed)+"\n"+str("no. of multiplication----:")+str(mul)+"\n"+str("no. of divisio-----------:")+str(div)+"\n"+str("total size---------------:")+str(total)) f.close() f1.close()