Python program to find prime numbers in a range and time taken to calculate

import time
lo = int(input("Enter lower range: "))
up = int(input("Enter upper range: "))
print("Prime numbers between",lo,"&",up,"are:\t")
start_time=time.time()
for n in range(lo,up + 1):
   if n > 1:
       for i in range(2,n):
           if (n % i) == 0:
               break
       else:
           print("\t\t\t",n)
elapsed_time = time.time() - start_time
print ("Time taken to calculate:",elapsed_time)

No comments: