Beispiel #1
0
def get_cnt(lim):
    rn = 1
    d = 2
    cnt = 0
    for i in range(lim):
        n = rn + d
        d_digits = mtools.separate_digits(d)
        n_digits = mtools.separate_digits(n)
        if len(n_digits) > len(d_digits):
            cnt = cnt + 1
        tmp = rn
        rn = d
        d = 2 * d + tmp
    return cnt
Beispiel #2
0
def possible_nums(n, d, i):
    nums = []
    base = [d] * (n - i)
    for j in range(10 ** i):
        l = base + mtools.separate_digits(j)
        if len(l) < n:
            l += [0] * (n - len(l))
        nums.append(l)
    return nums
Beispiel #3
0
def trunc_number(n, i, j):
    l = []
    while j >= i:
        s = mtools.separate_digits(n)
        m = int(mtools.combine_digits(s[:i]))
        r = int(mtools.combine_digits(s[i:]))
        if r > m:
            l.append((m, r))
        i += 1
    return l
Beispiel #4
0
def sum_digit(n):
    l = mtools.separate_digits(n)
    return sum(l)
Beispiel #5
0
def solve():
    ec = e_convergent(33)
    l = mtools.separate_digits(ec)
    l = [int(x) for x in l]
    return sum(l)
Beispiel #6
0
def has_property(n, m):
    return n == sum(mtools.separate_digits(m))
Beispiel #7
0
def sum_fac(n):
    l = mtools.separate_digits(n)
    l2 = [fac_tab[x] for x in l]
    return sum(l2)
Beispiel #8
0
def eventual(i, tab):
    if tab.has_key(i):
        return tab[i]
    l = mtools.separate_digits(i)
    i = sum([x * x for x in l])
    return tab[i]
Beispiel #9
0
def eventual_calc(i):
    while True:
        l = mtools.separate_digits(i)
        i = sum([x * x for x in l])
        if i == 1 or i == 89:
            return i