hdarwin

cstutoringcenter.com_Prime Numbers I

Dec 28th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. #!/usr/bin/env python
  2. def isPrime(num):
  3.     for x in range(2, num):
  4.         if ((num % x) == 0):return 0
  5.     return 1
  6.  
  7. sum = 0
  8. count = 0
  9. index = 1
  10. while True:
  11.     index = index + 1
  12.     if(isPrime(index) == 1):
  13.         count = count + 1
  14.         sum = sum + index
  15.         if(count == 250):break
  16. print sum
Advertisement
Add Comment
Please, Sign In to add comment