SHARE
TWEET

Untitled

DrDoom Nov 28th, 2012 103 Never
  1. x = 1
  2. u = 8793
  3. s1 = []
  4. s2 = []
  5.  
  6. k = 0
  7. y = 1
  8.  
  9. # get and store prime numbers between 1 and 8793 in s1
  10. while x < u:
  11.   if x.is_prime():
  12.     s1 = s1 + [x]
  13.   x = x + 1
  14.  
  15. # interate over the prime numbers and store the prime twins in s2
  16. while s1[y] < s1[len(s1) - 1]:
  17.   if (s1[k] + s1[y]) == ((s1[k]) + (s1[k] + 2)):
  18.     s2 = s2 + [s1[k]]
  19.     s2 = s2 + [s1[y]]
  20.   k = k + 1
  21.   y = y + 1
  22.  
  23. #output prime twins
  24. print s2
RAW Paste Data
Top