Last active
          August 29, 2015 13:56 
        
      - 
      
- 
        Save ami-GS/8841037 to your computer and use it in GitHub Desktop. 
    Nまでの素数のリストを出力
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | import sys | |
| import time | |
| s = time.time() | |
| N = int(sys.argv[1]) | |
| prime = [1]*N | |
| prime[0] = 0 | |
| prime[1] = 0 | |
| for i in range(2, int(N**0.5)): | |
| if prime[i]: | |
| for j in range(i*2, N, i): | |
| prime[j] = 0 | |
| ans = [i for i in range(N) if prime[i]] | |
| print ans, len(ans), time.time()-s | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment