Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!
tweet

# Untitled

By: a guest on Feb 3rd, 2013  |  syntax: Python  |  size: 0.89 KB  |  views: 54  |  expires: Never
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. #!/usr/bin/env python
2.
3. def isPrime(num):
4.     for x in range(2, (int(num**.5)+1)):
5.         if num % x == 0:
6.             return False
7.     return True
8.
9.
10. if __name__ == '__main__':
11.
12.     prime_numbers = []
13.
14.     for x in range(2, 1000000):
15.         if isPrime(x):
16.             prime_numbers.append(x)
17. #    print prime_numbers
18.
19.
20.     totalprime = 0
21.     for num in prime_numbers:
22.         num = str(num)
23.         num1 = list(num)
24. #        total = []
25.         primecount = 0
26.         for y in num1:
27.             temp = num1.pop(0)
28.             num1.append(temp)
29.             total = ''
30.             for x in num1:
31.                 total += x
32.             intTotal = int(total)
33.
34.             if isPrime(intTotal):
35.                 primecount += 1
36.                 if primecount == len(num):
37.                     totalprime += 1
38.     print "Total number of primes is:", totalprime
clone this paste RAW Paste Data
Top