pull down to refresh

68 is correct.
Are you sure about the ones larger than 100 though? Maybe you need to add all the primes up to that supposed candidate number in your primes list to make sure they don't end up breaking that "exactly two" constraint.
Ah, you're right about larger than 100. I can't find one larger than 68. Revised script:
import pandas as pd def get_primes(n): out = list() sieve = [True] * (n+1) for p in range(2, n+1): if (sieve[p]): out.append(p) for i in range(p, n+1, p): sieve[i] = False return out n = 100 primes = get_primes(n) data = [] for i in range(len(primes)): for j in range(i+1,len(primes)): x = primes[i] y = primes[j] z = x + y if z<=n: data.append({'z':z,'x':x,'y':y}) data = pd.DataFrame.from_dict(data) counts = data.groupby('z').agg(count=('z','count')).reset_index() counts.loc[counts['count']==2].sort_values(by='z',ascending=False).head(1)
I tried up to n=10,000 and nothing higher than 68 was found.
reply
def get_primes(n): out = list() sieve = [True] * (n+1) for p in range(2, n+1): if (sieve[p]): out.append(p) for i in range(p, n+1, p): sieve[i] = False return out
Fancy pancy there with your Sieve of Eratosthenes ;)
reply