mirror of
https://github.com/Noratrieb/benchmarks.git
synced 2026-01-14 18:55:02 +01:00
lmao python
This commit is contained in:
parent
a8eacce3c8
commit
4b0ec1a437
2 changed files with 33 additions and 3 deletions
27
primes/python/primes.py
Normal file
27
primes/python/primes.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue