hdarwin

cstutoringcenter.com_Prime Numbers III

Dec 28th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 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. count = 0
  9. for x in xrange(1000**2, 1, -1):
  10.         if(isPrime(x) == 1):
  11.                 total = 0
  12.                 for y in list(str(x)):
  13.                         total = total + int(y)
  14.                 if total == 14:count = count + 1
  15. print count
Advertisement
Add Comment
Please, Sign In to add comment