I have this program to list prime numbers within a certain range. the problem is the larger the number the slower it becomes. how can i use numpy to imporve the speeds? if not numpy, is there any other way to speed up the calculations?
from datetime import date
import time
import numpy as np
today = date.today()
lower = int(input("Starting Number: "))
upper = int(input("Ending Number: "))
print("Prime numbers between",lower,"and",upper,"are:")
with open("primenumbers.txt","a") as file:
file.write("\n")
file.write("{}".format(today))
file.write("\n")
start = time.time()
for num in range(lower,upper + 1):
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)
with open("primenumbers.txt","a") as file:
file.write("\n")
file.write("{}".format(num))
end = time.time()
print(end - start)
i want to process the data faster and please show some code.