## Pythagorean Triples

Here's an interesting math fact: the sum of any sequence of odd numbers from 1 to n is always a perfect square.

1 = 1

1+3 = 4

1+3+5 = 9

1+3+5+7 = 16

1+3+5+7+9 = 25

1+3+5+7+9+11 = 36

etc.

The sum is actually the square of (n+1)/2.

---------

What this also means is that every odd number can be expressed as a difference of consecutive squares:

1-0 = 1

4-1 = 3

9-4 = 5

16-9 = 7

25-16 = 9

36-25 = 11

etc.

In this case, each odd number n can be expressed as the square of (n+1)/2 minus the square of (n-1)/2.

---------

You can now use this knowledge to derive an infinite number of Pythagorean triples. For each odd number n greater than 1, these three values comprise a Pythagorean triple: n, (n^2-1)/2, (n^2+1)/2

3, 4, 5

5, 12, 13

7, 24, 25

9, 40, 41

11, 60, 61

13, 84, 85

etc.

Because of the relationship of the numbers, it's interesting to note that square of the first number equals the sum of the other two numbers. Obviously, these aren't the only Pythagorean triples that exist, but because there is an infinite number of odd numbers, and a unique triple can be derived for each odd number, there must be an infinite number of Pythagorean triples.

There are other ways use the information given here to derive different sets of Pythagorean triples, but I'll leave that to you to figure out!