tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
18
Task/Prime-decomposition/Python/prime-decomposition-2.py
Normal file
18
Task/Prime-decomposition/Python/prime-decomposition-2.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
primelist = [2,3]
|
||||
def is_prime(n):
|
||||
for y in primes():
|
||||
if not n % y: return False
|
||||
if n > y * y: return True
|
||||
|
||||
def primes():
|
||||
for n in primelist: yield n
|
||||
|
||||
n = primelist[-1] + 2
|
||||
while True:
|
||||
n += 2
|
||||
for x in primelist:
|
||||
if not n % x: break
|
||||
if x * x > n:
|
||||
primelist.append(n)
|
||||
yield n
|
||||
break
|
||||
Loading…
Add table
Add a link
Reference in a new issue