def test_factors_random(self): # Test the factors.factorise function with a random number. numfactors = random.randint(1, 8) values = [random.choice(PRIMES) for _ in range(numfactors)] values.sort() n = product(values) self.assertEqual(factors.factorise(n), values)
def test_factors_special(self): # Test the factors.factorise function with special values. self.assertEqual(factors.factorise(0), [0]) self.assertEqual(factors.factorise(1), [1]) self.assertEqual(factors.factorise(-1), [-1])
def test_factors_basic(self): # Basic test for factors.factorise. self.assertEqual(factors.factorise(2 * 7 * 31 * 31 * 101), [2, 7, 31, 31, 101])
def test_factors_basic(self): # Basic test for factors.factorise. self.assertEqual(factors.factorise(2*7*31*31*101), [2, 7, 31, 31, 101])
# Problem 3 from pyprimes.factors import factorise print('The solution is %d' % max(factorise(600851475143)))