21 lines
408 B
Python

def is_prime(x):
for p in range(3, int(x ** 0.5) + 1, 2):
if x % p == 0:
return False
return True
def search(percent):
n = 7
prime = 8
total = 13
while prime / total > percent:
n += 2
total += 4
for num in range((n - 3) * n + 3, n * n - 1, n - 1):
if is_prime(num):
prime += 1
return n
print(search(0.1))