def solve(): smallest_factor = Factors.smallestFactorOf(problemNumber) largest_factor = int(problemNumber/smallest_factor) for i in range(smallest_factor, largest_factor): if Factors.isFactor(problemNumber, i): counterpart = int(problemNumber/i) if Primes.is_prime(counterpart): return counterpart
def solve(): smallest_factor = Factors.smallestFactorOf(problemNumber) largest_factor = int(problemNumber / smallest_factor) for i in range(smallest_factor, largest_factor): if Factors.isFactor(problemNumber, i): counterpart = int(problemNumber / i) if Primes.is_prime(counterpart): return counterpart
def is_prime(number): if number == 2: return True if number %2 == 0 or number < 2: return False factor = 3 while factor*factor <= number: if Factors.isFactor(number, factor): return False factor += 1 return True
def divisbleByAll(number): for i in range(1,20): if(not Factors.isFactor(number, i)): return False return True
def divisbleByAll(number): for i in range(1, 20): if (not Factors.isFactor(number, i)): return False return True
def test_isFactorShouldReturnFalse(self): self.assertEqual(Factors.isFactor(14,3), False)
def test_isFactorShouldReturnTrue(self): self.assertEqual(Factors.isFactor(12,3), True)
def test_SmallestFactorOfShouldReturn3(self): self.assertEqual(Factors.smallestFactorOf(21), 3)
def test_SmallestFactorOfShouldReturn2(self): self.assertEqual(Factors.smallestFactorOf(24), 2)