hdarwin

cstutoringcenter.com_Sum of Primes

Dec 28th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import math
  3. def isPrime(num):
  4.         if num % 2 == 0:return 0
  5.         for x in range(2, int(math.ceil(math.sqrt(num)))+1):
  6.                 if ((num % x) == 0):return 0
  7.         return 1
  8.  
  9. total = 0
  10. for x in xrange(5000, 1, -1):
  11.         if(isPrime(x) == 1):total = total + x
  12. print total + 2
Advertisement
Add Comment
Please, Sign In to add comment