Created
March 28, 2011 12:16
-
-
Save yasuharu519/890359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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