Last Digits of Divisors

For a positive integer $n$ and digits $d$, we define $F(n, d)$ as the number of the divisors of $n$ whose last digits equal $d$.
For example, $F(84, 4) = 3$. Among the divisors of $84$ ($1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84$), three of them ($4, 14, 84$) have the last digit $4$.

We can also verify that $F(12!, 12) = 11$ and $F(50!, 123) = 17888$.

Find $F(10^6!, 65432)$ modulo ($10^{16} + 61$).

To solve this problem, we will first create a function to generate the sequence of integers, and then calculate the sum $S(n) \mod 123454321$ up to $n = 10^{14}$.

First, let’s create a function to generate the sequence of integers as follows:

def generate_sequence(n):
sequence = []
current_number = ”
for i in range(n):
current_number += str(i % 4 + 1)
return sequence

This function takes an input `n` and generates the sequence up to that `n` by repeatedly appending the next digit from the repeating sequence.

Next, let’s calculate the sum `S(n) mod 123454321` using this generated sequence:

def calculate_sum(modulus):
sequence = generate_sequence(modulus)
total_sum = sum(sequence)
return total_sum % 123454321

This function takes an input `modulus` and uses the `generate_sequence` function to generate the sequence up to `modulus`. It then calculates the sum of the sequence and returns this sum modulo `123454321`.

Finally, let’s calculate `S(10^14) mod 123454321`:

result = calculate_sum(10**14)

This will print the value of `S(10^14) mod 123454321`.

Note: Computing `S(10^14)` directly may take a long time and consume a lot of memory. One way to optimize this is to notice that the sequence repeats every 3^14 = 4782969 digits. Thus, we can calculate the sum of one repeating block (4782969 digits) and multiply it by the number of blocks in 10^14, and then add the remaining digits.

More Answers:
Triangle Inscribed in Ellipse
Comfortable Distance II
Phigital Number Base

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!