• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Feb 3rd, 2013 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
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
RAW Paste Data
Top