8-C language -C-1- Title: Decomposition Goldbach

Title: Goldbach decomposition

Goldbach conjecture that: even number of not less than 4 can be expressed as two prime numbers.

You do not need to prove this theorem, but are broken down even by a limited number of computers, verify if it works.

In fact, there is generally an even number of different decomposition scheme, we are concerned that the program contains a smaller prime numbers.
For a given range of values, we want to know these programs contain a smaller number of elements in the largest prime number is.

For example, less than 100, the number is 19, it is the contribution from the decomposition of 98.

Your request is less than 10,000, and this number is how much?

Note that you need to submit is an integer, do not fill in any extra content (for example, descriptive text)

def isprime(x):
    for k in range(2,int(x/2)):
        if x%k==0:
            return False
    return True

p=[]
for i in range(4,10001,2):
    for j in range(2,i):
        if isprime(j) and isprime(i-j):
            p.append(min(j,i-j))
            break
        
print(max(p))

answer:

173

Published 10 original articles · won praise 0 · Views 186

Guess you like

Origin blog.csdn.net/tianrandai12/article/details/104089843