Remainder of Polynomial Division

For positive integers $n$ and $m$, we define two polynomials $F_n(x) = x^n$ and $G_m(x) = (x-1)^m$.
We also define a polynomial $R_{n,m}(x)$ as the remainder of the division of $F_n(x)$ by $G_m(x)$.
For example, $R_{6,3}(x) = 15x^2 – 24x + 10$.
Let $C(n, m, d)$ be the absolute value of the coefficient of the $d$-th degree term of $R_{n,m}(x)$.
We can verify that $C(6, 3, 1) = 24$ and $C(100, 10, 4) = 227197811615775$.
Find $C(10^{13}, 10^{12}, 10^4) \bmod 999999937$.

To solve this problem, we will break it down into smaller steps and implement each step using Python code. Here’s a step-by-step solution:

Step 1: Generating Prime Numbers
First, we need a way to generate prime numbers. We can use the Sieve of Eratosthenes algorithm to efficiently generate all prime numbers up to a given limit.

def generate_primes(limit):
is_prime = [True] * (limit + 1)
is_prime[0] = is_prime[1] = False

for i in range(2, int(limit ** 0.5) + 1):
if is_prime[i]:
for j in range(i * i, limit + 1, i):
is_prime[j] = False

primes = [i for i in range(limit + 1) if is_prime[i]]
return primes

Step 2: Concatenating Primes
Next, we need a function to concatenate the first `n` primes together.

def concatenate_primes(n, primes):
concatenated = “”
for i in range(n):
concatenated += str(primes[i])
return int(concatenated)

Step 3: Concatenating Prime Multiples
We also need a function to concatenate `k` copies of the first `n` primes together.

def concatenate_prime_multiples(n, k, primes):
concatenated = “”
for i in range(k):
concatenated += str(concatenate_primes(n, primes))
return int(concatenated)

Step 4: Finding Contiguous Integer-Substrings
To find all contiguous integer-substrings, we can convert the number to a string and iterate through all possible substrings.

def find_integer_substrings(num):
num_str = str(num)
substrings = []

for i in range(len(num_str)):
for j in range(i + 1, len(num_str) + 1):
substr = int(num_str[i:j])

return substrings

Step 5: Summing the Integer-Substrings
Finally, we can sum all the integer-substrings and calculate the modulo.

def sum_integer_substrings(num):
substrings = find_integer_substrings(num)
return sum(substrings) % (10**9 + 7)

Putting it all together:
To solve the given problem, we can call the above functions with appropriate arguments.

primes = generate_primes(10**6)
result = sum_integer_substrings(concatenate_prime_multiples(10**6, 10**12, primes))

Note: The code provided above assumes that the `generate_primes` function is given the limit as $10^6$, corresponding to the number of primes required for the calculation. However, the algorithm and code are applicable for any positive integer `limit`. Also, be aware that the code above may take a considerable amount of time to execute due to the large values involved.

More Answers:
Writing $n$ as the Product of $k$ Distinct Positive Integers
Incenter and Circumcenter of Triangle
Drunken Tower of Hanoi


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!