Esempio n. 1
0
def gen_circular_primes(primeList, bound):
    """Generate circular primes until the bound is reached.
    """
    extend_primes(primeList, bound)

    for p in primeList:
        # test if circular

        isCircular = True
        for rot in gen_rotations(p):
            if binary_search(rot, primeList) < 0:
                isCircular = False
                break

        if isCircular:
            yield p
Esempio n. 2
0
def is_abundant_splittable(n, primes = None, abundants = [12]):
    """Given number n, return True if it can be witeen as a sum of two abundant numbers."""
    if abundants[-1] < n - 12:
        expand_abundants(n, primes, abundants)
        
    halfIndex = len(abundants) // 2

    for i in xrange(0, len(abundants)):
        abundant = abundants[i]
        if listutils.binary_search(n-abundant, abundants, i, len(abundants)-1) >= 0:
            return True

        if abundant > (abundants[-1] // 2 ):
            break

    return False