Ah, that edit is much better :) I got the formulas when I was working on a problem for the Putnam math competition. I showed that a problem was equivalent to stating that every integer greater than 2 was part of a Pythagorean triple, which was much easier to show than the original problem. Then I worked at creating the function. My original proof is not at all elegant, but it went like this:

Let a,b,c be natural numbers greater than 2 that satisfy a^{2}+b^{2}=c^{2. We know a≠b since that would imply 2a}2^{=c}2^^ → sqrt(2)=c/a which is not true since sqrt(2) is irrational. so let a<b<c. We know that the difference (b+1)^{2}-b^{2} is 2b+1, which is odd, so if we can get a^{2}=2b+1, then we have a^{2}+b^{2}=(b+1)^{2}, so we know c=b+1. If we are given a, then b=(a^{2}-1)/2, which works when a is odd.

So now, for all odd values of a, we can create the Pythagorean triple a^{2}+(a^{2}-1)^{2}/4=(a^{2}+1)^{2}/4.

Now for the evens, just look at c=b+2. Then a^{2}=(b+2)^{2}-b^{2}=4b+4, so b=(a^{2}-4)/4= a^{2}/4-1 and so we have a triple that all even values of a are a part of.

Now the fun part comes in by smushing the two equations together such that odd values of a use the first equation and even values of a use the second. All I did was find the average of the two equations and then I subtract the difference for add a, add the difference for even a. This is really tough to describe, so don't worry if this is gibberish.

Add the two equations together and divide by 2. I will just do this with the formula for finding b:

((a^{2}-1)/2+a^{2}/4-1)/2

((2a^{2}-2)/4+(a^{2}-4)/4)/2

((2a^{2}-2+a^{2}-4)/4)/2

(3a^{2}-6)/8

Now we find the difference between that and either the equation for odd a or even a (it should be the same, since we took the average):

(a^{2}-1)/2-(3a^{2}-6)/8

(4a^{2}-4)/8-(3a^{2}-6)/8

(4a^{2}-4-3a^{2}+6)/8

(a^{2}+2)/8

Now if we want to add that when a is odd and subtract when it is even, we need to use the fact that (-1)^{a} is 1 if a is even, -1 if a is odd:

(3a^{2}-6)/8-(-1)^a(a^{2}+2)/8

But since the have the same denominator:

b=((3a^{2}-6)-(-1)^a(a^{2}+2))/8

And you will find for c:

c=((3a^{2}+6)-(-1)^a(a^{2}-2))/8

So to make it look prettier:

Given $a$:

$b=\frac{3a^{2}-6-(-1)^{a}(a^{2}+2)}{8}$

$c=\frac{3a^{2}+6-(-1)^{a}(a^{2}-2)}{8}$

You can derive more formulas this way, too, so have fun ! Now you know that every integer greater than 2 can be a leg of a right triangle whose lengths form a Pythagorean triple.