Skip to content

Instantly share code, notes, and snippets.

@jzau
Last active December 26, 2015 10:29
Show Gist options
  • Select an option

  • Save jzau/7137202 to your computer and use it in GitHub Desktop.

Select an option

Save jzau/7137202 to your computer and use it in GitHub Desktop.
print all prime which less than N using python
import math
N = 200000
M = int(math.sqrt(N)) + 1;
a = [1]*N
for i in range(3, M, 2):
for j in range(i+i, N, i):
a[j]=0
print 2
for i in range(3, N, 2):
if a[i] == 1:
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment