Skip to content

Instantly share code, notes, and snippets.

@kratsg
Last active August 29, 2015 14:11
Show Gist options
  • Save kratsg/2a27668fd6e33218dd0f to your computer and use it in GitHub Desktop.
Save kratsg/2a27668fd6e33218dd0f to your computer and use it in GitHub Desktop.
def get_primes(n):
numbers = set(range(n, 1, -1))
primes = []
while numbers:
p = numbers.pop()
primes.append(p)
numbers.difference_update(set(range(p*2, n+1, p)))
return primes
primes = get_primes(500)
from itertools import combinations
for i, j, k in combinations(primes, 3):
if i+j+k == 500:
print i,j,k
2 7 491
2 11 487
2 19 479
2 31 467
2 37 461
2 41 457
2 59 439
2 67 431
2 79 419
2 89 409
2 97 401
2 101 397
2 109 389
2 131 367
2 139 359
2 149 349
2 151 347
2 167 331
2 181 317
2 191 307
2 227 271
2 229 269
2 241 257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment