Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: DrDoom on Nov 28th, 2012  |  syntax: Python  |  size: 0.42 KB  |  hits: 39  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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