Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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])
Example #4
0
 def test_factors_basic(self):
     # Basic test for factors.factorise.
     self.assertEqual(factors.factorise(2 * 7 * 31 * 31 * 101),
                      [2, 7, 31, 31, 101])
Example #5
0
 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])
Example #6
0
 def test_factors_basic(self):
     # Basic test for factors.factorise.
     self.assertEqual(factors.factorise(2*7*31*31*101), [2, 7, 31, 31, 101])
Example #7
0
# Problem 3
from pyprimes.factors import factorise

print('The solution is %d' % max(factorise(600851475143)))