Untitled
raw download clone
TEXT
views 11
,
size 576 b
def gen_prime_numbers(x):
	prime=[True]*x
	for i in range(2,int(math.ceil(math.sqrt(x)))): 
		if prime[i]:  
			j=i*i
			while j<x:
				prime[j]=False
				j+=i
	new_prime = list()
	for i, value in enumerate(prime):
		if value == True:
			new_prime.append(i)
	return new_prime



def simple(n):
	if not simple.cache:
		simple.cache = gen_prime_numbers(10000)
	if n in simple.cache:
		return True
	else:
		if n > max(simple.cache):
			simple.cache = gen_prime_numbers(n * 2)
			return simple(n)
		return False

simple.cache = None

print(simple(17))
close fullscreen
Login or Register to edit or fork this paste. It's free.