Просто шукаємо прості числа:
import time
def prime_num1(n):
primes = list()
for num in range(1, n+1):
prime = True
for i in range(2, num):
if (num % i == 0):
prime = False
if prime:
primes.append(num)
return primes
start = time.time()
print(prime_num1(10000))
end = time.time()
print("elapsed time: "+str(end - start)+" sec") |