December SPECIAL! For a limited time only. Get 20% discount on a LIFETIME PRO account!Want more features on Pastebin? Sign Up, it's FREE!
tweet
Guest

Untitled

By: a guest on Sep 6th, 2015  |  syntax: Python  |  size: 0.31 KB  |  views: 75  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print  |  QR code  |  clone
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def primes(up_to):
  2.         numbers = range(up_to)
  3.         i = 2
  4.         out = False
  5.         while True:
  6.                 if not len(numbers) == numbers.index(i)+1:
  7.                         future = numbers[numbers.index(i)+1]
  8.                 else:
  9.                         out = True
  10.                 for x in range(2*i, up_to, i):
  11.                         if x in numbers:
  12.                                 numbers.remove(x)
  13.                 if out:
  14.                         break
  15.                 i = future
  16.         return numbers
clone this paste RAW Paste Data
Top