Ejemplo n.º 1
0
from commons import runtime
from mathh import factorial


def resolve():
    print(sum([int(c) for c in str(factorial(100))]))


runtime(resolve)
Ejemplo n.º 2
0
    for x in range(500001, 999999, 2):
        c = new_fn(x)
        if c > longest_chain:
            longest_chain = c
            longest_owner = x
    print(longest_owner)


thread_generated_lengths = {1: 1}


def thread_fn(n):
    if n not in thread_generated_lengths:
        thread_generated_lengths[n] = thread_fn(
            n // 2) + 1 if n % 2 == 0 else thread_fn((3 * n + 1) // 2) + 2
    return thread_generated_lengths[n]


def thread_resolve():
    longest_chain = 0
    longest_owner = 0
    for x in range(1, 1000000):
        c = thread_fn(x)
        if c > longest_chain:
            longest_chain = c
            longest_owner = x
    print(longest_owner)


runtime(new_resolve)