Esempio n. 1
0
def main():
    totalCount, totalPrime = 0, 0
    while (totalPrime < 10001):
        totalCount += 1
        if (isPrime(totalCount)):
            totalPrime += 1
    print('The 10001st prime number is: %i' % (totalCount))
Esempio n. 2
0
 def testPrime(self):
     self.assertEqual(isPrime(1), False)
     self.assertEqual(isPrime(2), True)
     self.assertEqual(isPrime(3), True)
     self.assertEqual(isPrime(4), False)
     self.assertEqual(isPrime(5), True)
     self.assertEqual(isPrime(6), False)
     self.assertEqual(isPrime(9), False)
     self.assertEqual(isPrime(23), True)
Esempio n. 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Problem 10
# http://projecteuler.net/index.php?section=problems&id=10
#
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
# Find the sum of all the primes below two million.
#
# Solved by Evaldo Junior <*****@*****.**>
# November, 15th - 2010
#
import sys
sys.path.append("libs")
from myprime import isPrime

primes_sum = 0

for i in range(2, 2000000):
    if isPrime(i):
        primes_sum += i

print("The sum of all primes below two million is %i" % (primes_sum))