<jupyter_start><jupyter_text>Euler Problem 231 The binomial coefficient 10C3 = 120.120 = 23 × 3 × 5 = 2 × 2 × 2 × 3 × 5, and 2 + 2 + 2 + 3 + 5 = 14.So the sum of the terms in the prime factorisation of 10C3 is 14.Find the sum of the terms in the prime factorisation of 20000000C15000000.<jupyter_code>def digitsum(n, p):
    """Sum of digits of n in base p"""
    s = 0
    while n:
        s += n % p
        n //= p
    return s


def binom(n, k, p):
    """Exponent of p in the prime factorization of (n choose k)."""
    return (digitsum(k, p) + digitsum(n - k, p) - digitsum(n, p)) // (p - 1)

from primesieve import primes

def sum_of_prime_factors_binom(n, k):
    return sum(p * binom(n, k, p) for p in primes(n))

print(sum_of_prime_factors_binom(20000000, 15000000))<jupyter_output>7526965179680
{'fraction_non_alphanumeric': 0.11925465838509317, 'fraction_numerical': 0.09937888198757763, 'mean_word_length': 3.1122448979591835, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '6592', 'license': 'MIT', 'n_tokens_mistral': 377, 'n_tokens_neox': 296, 'n_words': 117, 'path': 'Euler 231 - The prime factorisation of binomial coefficients.ipynb', 'repo_name': 'Radcliffe/project-euler', 'size': '805'}