$ABC$ is an integer sided triangle with incenter $I$ and perimeter $p$.
The segments $IA$, $IB$ and $IC$ have integral length as well.
Let $L = p + |IA| + |IB| + |IC|$.
Let $S(P) = \sum L$ for all such triangles where $p \le P$. For example, $S(10^3) = 3619$.
Find $S(10^7)$.
To find $M(137)$, we need to calculate the harmonic numbers and check the divisibility of their denominators by $137$ until we find the largest value of $n$ where the denominator is not divisible by $137$.
We can solve this problem by using Python. Below is the implementation:
“`python
from fractions import Fraction
def gcd(a, b):
# Function to calculate the greatest common divisor
while b:
a, b = b, a % b
return a
def M(p):
n = 1 # Start with the first harmonic number
while True:
# Calculate the denominator of the current harmonic number
denominator = 1
for k in range(1, n+1):
denominator *= k
# Check if the denominator is divisible by p
if denominator % p != 0:
prev_denominator = denominator
else:
return n-1 if prev_denominator is None else n-2
n += 1
# Find M(137)
result = M(137)
print(result)
“`
The code begins by defining a function `gcd` to calculate the greatest common divisor. This will be used later to find the reduced fraction.
The `M` function takes an input `p` and iterates through the harmonic numbers until it finds a denominator that is not divisible by `p`. It initializes `n` to `1` and enters an infinite loop (`while True`).
Inside the loop, the code calculates the denominator of the current harmonic number by multiplying all the positive integers up to `n`. It then checks if the denominator of the current harmonic number is divisible by `p`. If it is not, it stores the previous denominator in a variable `prev_denominator` and continues to the next iteration. If it is divisible by `p`, it returns `n-1` if `prev_denominator` is `None` (indicating that this is the first harmonic number), or `n-2` (indicating the largest value of `n` where the denominator is not divisible by `p`).
Finally, the code calls the `M` function with `137` as the input and prints the result.
Executing this code will provide the value of `M(137)`, which is the largest value of `n` such that the denominator of the harmonic number is not divisible by `137`.
More Answers:
Roots on the RiseThe Last Question
Chef Showdown