Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Created March 28, 2011 12:16
Show Gist options
  • Save yasuharu519/890359 to your computer and use it in GitHub Desktop.
Save yasuharu519/890359 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
N = 10000
def main():
numList = range(1, N + 1)
# 1を除く
numList.pop(0)
count = numList[0]
sosuu = []
sosuu_num = 1
while sosuu_num < math.sqrt(N):
sosuu_num = numList.pop(0)
sosuu.append(sosuu_num)
numList = [x for x in numList if x % sosuu_num != 0]
sosuu.extend(numList)
print N,"までの素数"
print sosuu
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment