Divisibility Comparison Between Factorials

Let $f_5(n)$ be the largest integer $x$ for which $5^x$ divides $n$.
For example, $f_5(625000) = 7$.

Let $T_5(n)$ be the number of integers $i$ which satisfy $f_5((2 \cdot i – 1)!) \lt 2 \cdot f_5(i!)$ and $1 \le i \le n$.
It can be verified that $T_5(10^3) = 68$ and $T_5(10^9) = 2408210$.

Find $T_5(10^{18})$.

To find $T_5(10^{18})$, we need to calculate the number of integers $i$ that satisfy the given conditions in the range $1 \leq i \leq 10^{18}$.

We can approach this problem by iterating over all values of $i$ in the range and count the number of valid values. However, this approach would be inefficient due to the large input size.

Instead, we can make use of mathematical observations and properties to optimize our solution.

Observations:
1. $f_5(n)$ represents the largest exponent of $5$ that divides $n$. For example, $f_5(625000) = 7$ because $5^7$ divides $625000$ but $5^8$ does not.
2. Since $f_5((2 \cdot i – 1)!)$ is the largest exponent of $5$ that divides $(2 \cdot i – 1)!$, and $f_5(i!)$ is the largest exponent of $5$ that divides $i!$, the condition $f_5((2 \cdot i – 1)!) \lt 2 \cdot f_5(i!)$ can be rewritten as $f_5((2 \cdot i – 1)!)/f_5(i!) \lt 2$.

Based on these observations, we can proceed with the following approach:

1. Initialize a variable `count` as 0 to keep track of the number of valid values of $i$.
2. Iterate over the range $1 \leq i \leq 10^{18}$.
3. For each value of $i$, calculate $f_5((2 \cdot i – 1)!)$ and $f_5(i!)$.
4. If $f_5((2 \cdot i – 1)!)/f_5(i!) \lt 2$, increment the `count` variable by 1.
5. After iterating over all values of $i$, the final value of `count` will be the answer.

Now, let’s implement this approach in Python code:

“`python
def largest_exponent_of_5(n):
count = 0

while n % 5 == 0:
count += 1
n //= 5

return count

def T_5(n):
count = 0

for i in range(1, n + 1):
exponent_1 = largest_exponent_of_5((2 * i – 1))
exponent_2 = largest_exponent_of_5(i)

if (exponent_1 / exponent_2) < 2: count += 1 return count result = T_5(10**18) print(result) ``` The code defines two helper functions. The `largest_exponent_of_5` function calculates the largest exponent of $5$ that divides a given number $n$. The `T_5` function implements the main logic to count the number of valid values of $i$. Finally, we call the `T_5` function with the input value of $10^{18}$ and print the result.

More Answers:
Amazing Mazes!
$(\text{prime}-k)$ Factorial
Generating Polygons

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

Share:

Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!