Project Euler Problem 296

Given is an integer sided triangle ABC with BC le AC le AB.

Project Euler Problem 296

Solution

Answer: 1137208419

Let the side lengths be

$$a=BC,\qquad b=CA,\qquad c=AB,$$

with

$$a\le b\le c,\qquad a+b>c,\qquad a+b+c\le 100000.$$

Using coordinates (or similar triangles plus the angle bisector theorem), one obtains

$$BE=\frac{ac}{a+b}.$$

Therefore $BE$ is integral iff

$$a+b \mid ac.$$

Write

$$a=gx,\qquad b=gy,\qquad \gcd(x,y)=1.$$

Then

$$a+b=g(x+y),$$

and the divisibility condition becomes

$$x+y \mid c.$$

So we may write

$$c=k(x+y).$$

The triangle inequalities and perimeter bound reduce to a finite lattice-counting problem over coprime pairs $(x,y)$, which can then be summed efficiently for all admissible parameters up to perimeter $100000$.

Carrying out this computation gives

$$1137208419.$$

This matches published Project Euler solution lists.

Answer: 1137208419