## Project Euler 138: Investigating isosceles triangle for which the height and base length differ by one.

#### Problem Description

Consider the isosceles triangle with base length, *b* = 16, and legs, L = 17.

By using the Pythagorean theorem it can be seen that the height of the triangle, *h* = √(17^{2} − 8^{2}) = 15, which is one less than the base length.

With *b* = 272 and L = 305, we get *h* = 273, which is one more than the base length, and this is the second smallest isosceles triangle with the property that *h* = *b* ± 1.

Find ∑ L for the twelve smallest isosceles triangles for which *h* = *b* ± 1 and *b*, L are positive integers.

#### Analysis

There are two ways to solve this problem. The first is to generate some triangles that match the requirements and search for an integer sequence; which we found. It turns out that **one-half** of every 6th iteration of the Fibonacci sequence, starting at the 9th, yields a solution for L. Namely: 34, 610, 10946, 196418, etc. or F(6n+3), n=1..12.

The second way, and actually more intuitive, is to solve for the Diophantine quadratic equation as:

(assuming x for b/2 to achieve integer coefficient for the resulting equation)

Take a run over to: http://www.alpertron.com.ar/QUAD.HTM, and plug in the coefficients to calculate:

5 xby Dario Alejandro Alpern X^{2}- y^{2}+ 4 x + 1 = 0_{0}= 0 Y_{0}= -1 and also: X_{0}= 0 Y_{0}= 1X

P = -9 Q = -4 K = -4 R = -20 S = -9 L = -8_{n+1}= P X_{n}+ Q Y_{n}+ K Y_{n+1}= R X_{n}+ S Y_{n}+ L

We verified this solution, but never had the need to implement it.

#### Project Euler 138 Solution

Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 138 Solution Python 2.7 source.

#### Afterthoughts

- Reference: The On-Line Encyclopedia of Integer Sequences (OEIS) A007805: a(n)=F(6n+3)/2, where F=the Fibonacci sequence.

*Project Euler 138 Solution last updated*

Clearly the constant parameter should be 2, not 1.

For 2 Dario’s website says there are no answers, care to explain how exactly you’ve verified that solution?

Nevermind, my mistake

No problem. Glad you worked it out.