Skip to content

Instantly share code, notes, and snippets.

@CreateRemoteThread
Created June 25, 2016 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CreateRemoteThread/7c05302c3e515d70d664e6b3e3ea9491 to your computer and use it in GitHub Desktop.
Save CreateRemoteThread/7c05302c3e515d70d664e6b3e3ea9491 to your computer and use it in GitHub Desktop.
import os
import errno
import math
def draw():
current = 2
check_map("2")
print 'Press Ctrl + C to stop draw map'
while 1:
try:
current = find_next_prime(current)
check_map(str(current))
except KeyboardInterrupt:
break
def check_map(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno !=errno.EEXIST:
raise
def find_next_prime(current):
flag = False
for p in range(current+1, current*2):
for i in range(2, int(math.sqrt(p)) + 1):
if p % i == 0:
flag = True
break
if flag == False:
return p
else:
flag = False
draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment