def test_prime_check_small(self): result = problem3.is_prime(2) self.assertTrue(result)
def test_prime_check_small_non_prime(self): result = problem3.is_prime(4) self.assertFalse(result)
def test_prime_check_large(self): result = problem3.is_prime(6857) self.assertTrue(result)
def test_prime_check_large_non_prime(self): result = problem3.is_prime(6858) self.assertFalse(result)
#!/usr/bin/python """ (c) projecteuler.net 10001st prime Problem 7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? """ from problem3 import is_prime i = 2 k = 1 while k != 10001: i += 1 if is_prime(i): k += 1 print i
# 10001st prime # Answer: 104743 from problem3 import is_prime max_count = int(input()) i = 2 prime_number = i count = 0 while count < max_count: if is_prime(i): prime_number = i count += 1 i += 1 print(prime_number)
def sum_of_primes(limit): total = 0 for i in range(2, limit): if is_prime(i): total += i return total