Untitled
raw download clone
TEXT
views 24
,
size 463 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
	return 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

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