Ejemplo n.º 1
0
def truncatable_prime(num):
    digit = solutions.get_digits(num)
    divisor = 1
    while num / divisor:
        val = num / divisor
        if not solutions.is_prime(val) or val == 1:
            return False
        val = num % divisor
        if val == 1:
            return False
        elif val > 0 and not solutions.is_prime(val):
            return False
        divisor *= 10

    return True
Ejemplo n.º 2
0
def num_to_words(num, items=None):
    items = items or []
    if num in num_to_word:
        items.append(num)
        return items

    digit = solutions.get_digits(num)
    nth = 10 ** (digit - 1)
    div = num / nth
    rem = num % nth
    if div * nth in num_to_word:
        items.append(div * nth)
    else:
        items.append((div, nth))

    if rem in num_to_word:
        items.append(rem)
    elif rem >= 1:
        num_to_words(rem, items)

    return items