예제 #1
0
def solve():
    smallest_factor = Factors.smallestFactorOf(problemNumber)
    largest_factor = int(problemNumber/smallest_factor)

    for i in range(smallest_factor, largest_factor):
    
        if Factors.isFactor(problemNumber, i):
            counterpart = int(problemNumber/i)
    
            if Primes.is_prime(counterpart):
                return counterpart
예제 #2
0
def solve():
    smallest_factor = Factors.smallestFactorOf(problemNumber)
    largest_factor = int(problemNumber / smallest_factor)

    for i in range(smallest_factor, largest_factor):

        if Factors.isFactor(problemNumber, i):
            counterpart = int(problemNumber / i)

            if Primes.is_prime(counterpart):
                return counterpart
예제 #3
0
#Find the sum of all the primes below two million.

from modules import Primes

problem_number = 2000000
primes = Primes.prime_numbers_below(problem_number)

prime_sum = sum(primes)

print(primes)
print(prime_sum)
예제 #4
0
 def test_isPrimeShouldReturnFalse(self):
     self.assertEqual(Primes.is_prime(9), False)
예제 #5
0
 def test_isPrimeShouldReturnTrue(self):
     self.assertEqual(Primes.is_prime(23), True)
예제 #6
0
 def test_prime_numbers_below_10(self):
     primes = Primes.prime_numbers_below(10)
     self.assertListEqual(primes, [2, 3, 5, 7])
예제 #7
0
 def test_nth_prime_number_2nd(self):
     self.assertEqual(Primes.nth_prime_number(2), 3)
예제 #8
0
 def test_nth_prime_number_6th(self):
     self.assertEqual(Primes.nth_prime_number(6), 13)
예제 #9
0
#What is the 10 001st prime number?

from modules import Primes

print(Primes.nth_prime_number(10001))