Пример #1
0
    def test_prime_factors(self):
        # Loop downwards so we don't have to keep re-seiving the prime list
        for num in xrange(10000,2,-1):
            factors = primes.prime_factors(num)
            if not factors:
                self.assertTrue(primes.is_prime(num), 'No factor list returned for non-prime %d' % num)
                continue
            product = reduce(op.mul, factors)

            self.assertEqual(product, num, 'Incorrect factor list for %d: (%s) = %d' % (num, "*".join(map(str, factors)), product))
Пример #2
0
def problem_three():
    """
    Return the largest prime factor of the number 600851475143
    """
    return reduce(max,prime_factors(600851475143))