lmao python

This commit is contained in:
nora 2021-06-06 21:23:40 +02:00
parent a8eacce3c8
commit 4b0ec1a437
2 changed files with 33 additions and 3 deletions

27
primes/python/primes.py Normal file
View file

@ -0,0 +1,27 @@
import time
from math import sqrt
def primes(max):
primes_list = [2]
for i in range(3, max):
is_prime = True
for prime in primes_list:
if prime > sqrt(i):
break
if i % prime == 0:
is_prime = False
break
if is_prime:
primes_list.append(i)
return primes_list
start_millis = round(time.time() * 1000)
primes(10_000_000)
total_millis = round(time.time() * 1000) - start_millis
print(total_millis)