46.py 401 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. from utils import primes_until
  3. MAX = 10000
  4. comps = [False] * MAX
  5. comps[1] = True
  6. for p in primes_until(MAX - 1):
  7. q = 1
  8. comps[p] = True
  9. while True:
  10. pplusq = p + 2 * q ** 2
  11. if pplusq >= MAX:
  12. break
  13. comps[pplusq] = True
  14. q += 1
  15. for i, passed in enumerate(comps):
  16. if i & 1 and not passed:
  17. print i
  18. break