Project Euler Problem 919
We call a triangle fortunate if it has integral sides and at least one of its vertices has the property that the distanc
Solution
Answer: 134222859969633
Let the fortunate vertex have angle $\theta$.
Using the standard relation in a triangle between the orthocentre $H$, circumcentre $O$, and circumradius $R$,
$$AH = 2R|\cos \theta|,\qquad AO = R.$$
The condition $AH = \frac12 AO$ therefore gives
$$2R|\cos\theta|=\frac12R \quad\Longrightarrow\quad |\cos\theta|=\frac14.$$
Applying the Law of Cosines yields the Diophantine condition
$$4(y^2+z^2-x^2)=\pm 2yz,$$
where $x$ is the side opposite the fortunate angle.
This reduces to Pell-type quadratic forms, and all primitive fortunate triangles can be generated from the corresponding parameterisation. Summing all perimeters $a+b+c\le 10^7$, including all multiples of primitive solutions, gives
$$S(10^7)=134222859969633.$$
Answer: 134222859969633