<jupyter_start><jupyter_text>Problem 700 One Million Members**On Sunday 5 April 2020 the Project Euler membership first exceeded one million members. We would like to present this problem to celebrate that milestone. Thank you to everyone for being a part of Project Euler.**The number $6$ can be written as a palindromic sum in exactly eight different ways:$$(1, 1, 1, 1, 1, 1), (1, 1, 2, 1, 1), (1, 2, 2, 1), (1, 4, 1), (2, 1, 1, 2), (2, 2, 2), (3, 3), 6$$We shall define a twopal to be a palindromic tuple having at least one element with a value of $2$. It should also be noted that elements are not restricted to single digits. For example, $(3, 2, 13, 6, 13, 2, 3)$ is a valid twopal.If we let $t(n)$ be the number of twopals whose elements sum to $n$, then it can be seen that $t(6) = 4$:$$(1, 1, 2, 1, 1), (1, 2, 2, 1), (2, 1, 1, 2), (2, 2, 2)$$Similarly, $t(20) = 824$.In searching for the answer to the ultimate question of life, the universe, and everything, it can be verified that $t(42) = 1999923$, which happens to be the first value of $t(n)$ that exceeds one million.However, your challenge to the "ultimatest" question of life, the universe, and everything is to find the least value of $n > 42$ such that $t(n)$ is divisible by one million.OEIS Sequence: [A005251](https://oeis.org/A005251) Solution$$t(2n) = 2 ^ n - f(n + 2)$$$$f(n) = 2f(n - 1) - f(n - 2) + (n - 3)$$<jupyter_code>def compute(modulo: int) -> int:
    n = (4, 2, 1)
    power = i = 4
    result = 1
    while result:
        n = (2 * n[0] - n[1] + n[2]) % modulo, n[0], n[1]
        power = power * 2 % modulo
        result = power - n[1]
        i += 2
    return i
compute(1_000_000)
%timeit -n 10 -r 1 -p 6 compute(1_000_000)<jupyter_output>186.13 ms ± 0 ns per loop (mean ± std. dev. of 1 run, 10 loops each)
{'fraction_non_alphanumeric': 0.14007782101167315, 'fraction_numerical': 0.07837687604224569, 'mean_word_length': 3.4226044226044228, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '612417', 'license': 'MIT', 'n_tokens_mistral': 742, 'n_tokens_neox': 624, 'n_words': 298, 'path': 'problems/0710/solution.ipynb', 'repo_name': 'Dynortice/didactic-rotary-phone', 'size': '1799'}