예제 #1
0
def curious(x, primes):
    # First, check right truncation
    val = x
    for i in range(euler_util.length(x) - 1):
        val = rtrunc(val)
        if euler_util.bsearch(primes, val) == -1:
            return False

    # next, check left truncation
    val = x
    for i in range(euler_util.length(x) - 1):
        val = ltrunc(val)
        if euler_util.bsearch(primes, val) == -1:
            return False

    return True
예제 #2
0
def run():
    count = 0
    for p in range(1,22):
        for x in eu.numbers(1):
            l = eu.length(pow(x,p))
            if l > p:
                break
            if l == p:
                count += 1
    return count
예제 #3
0
def topheavy(num, den):
    return eu.length(num) > eu.length(den)