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.
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