Beispiel #1
0
def get_all_divisors(n):
	l = []
	for base in range(2,10+1):
		new_n = int(n, base)
		divisor = factors.factors(new_n).next()[0]
		l.append(divisor)
	return l
Beispiel #2
0
 def test_factors_extra(self):
     # Test factorise with _EXTRA_CHECKS enabled.
     if __debug__:
         self.assertTrue(hasattr(factors, '_EXTRA_CHECKS'))
         # Monkey-patch the factors module to ensure the extra checks
         # are exercised.
         save = factors._EXTRA_CHECKS
         factors._EXTRA_CHECKS = True
     else:
         self.assertFalse(hasattr(factors, '_EXTRA_CHECKS'))
     try:
         values = [2, 2, 2, 3, 17, 17, 29, 31, 61, 61, 103, 227, 227]
         n = product(values)
         expected = [(2, 3), (3, 1), (17, 2), (29, 1), (31, 1), (61, 2),
                     (103, 1), (227, 2)]
         actual = list(factors.factors(n))
         self.assertEqual(actual, expected)
     finally:
         if __debug__:
             factors._EXTRA_CHECKS = save
Beispiel #3
0
 def test_factors_extra(self):
     # Test factorise with _EXTRA_CHECKS enabled.
     if __debug__:
         self.assertTrue(hasattr(factors, '_EXTRA_CHECKS'))
         # Monkey-patch the factors module to ensure the extra checks
         # are exercised.
         save = factors._EXTRA_CHECKS
         factors._EXTRA_CHECKS = True
     else:
         self.assertFalse(hasattr(factors, '_EXTRA_CHECKS'))
     try:
         values = [2, 2, 2, 3, 17, 17, 29, 31, 61, 61, 103, 227, 227]
         n = product(values)
         expected = [(2, 3), (3, 1), (17, 2), (29, 1), (31, 1),
                     (61, 2), (103, 1), (227, 2)]
         actual = list(factors.factors(n))
         self.assertEqual(actual, expected)
     finally:
         if __debug__:
             factors._EXTRA_CHECKS = save
Beispiel #4
0
 def test_factors(self):
     values = [2, 3, 3, 3, 3, 29, 29, 31, 101, 137]
     n = product(values)
     expected = [(2, 1), (3, 4), (29, 2), (31, 1), (101, 1), (137, 1)]
     actual = list(factors.factors(n))
     self.assertEqual(actual, expected)
Beispiel #5
0
 def test_factors(self):
     values = [2, 3, 3, 3, 3, 29, 29, 31, 101, 137]
     n = product(values)
     expected = [(2, 1), (3, 4), (29, 2), (31, 1), (101, 1), (137, 1)]
     actual = list(factors.factors(n))
     self.assertEqual(actual, expected)