Guest User

ps1aMK2.py

a guest
Mar 9th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Problem set 1a
  2. #Name: ##
  3. #Time:  
  4.  
  5. prime_count = 1
  6.  
  7. prime_cand = 3
  8.  
  9. test_divisor = 2
  10.  
  11. while prime_count < 1000:
  12.     while not prime_cand % test_divisor == 0:
  13.         if test_divisor < (prime_cand / 2):
  14.             test_divisor = test_divisor + 1
  15.         else:
  16.             print prime_cand
  17.             prime_cand = prime_cand + 2
  18.             prime_count = prime_count + 1
  19.             test_divisor = 2
  20.            
  21.     test_divisor = 2
  22.     prime_cand = prime_cand + 2
  23.    
  24. print 'The 1000th prime is : ', (prime_cand - 4)
Advertisement
Add Comment
Please, Sign In to add comment