Project Euler 296 - Angular Bisector and Tangent

Official link:

Note: My code takes around ~840s

Thought Process

Using GeoGebra, which I have included a little applet of, we can clearly see that 

The proof of these 2 are not difficult but rather tedious, lots of good examples in the discussion forum!

Then using the Angular Bisector Theorem we have that AD/BD = AC/BC, combining all of this with AD + BD = AB we get BE = (AB*BC)/(AC + BC)

Let d = gcd(AC, BC) => AC = d*AC', BC = d*BC' where gcd(AC', BC') = 1

We then have that BE = (AB*BC')/(AC' + BC') and clearly AC' + BC' cannot divide BC' therefore (AC' + BC') divides AB

Now we know that AB is between the first multiple of (AC' + BC') that is greater than AC and the minimum of (BC + AC) and  (100,000 - AC - BC) by the Triangle Inequality

Interactive Code

Enter a number (yourinput)

Code will output the number of triangles ABC with a perimeter not exceeding yourinput and BE has integral length