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.

]]>` ``randInt(3,99 .125{8Ans,3Ans²-6-(-1)^Ans(Ans²+2),3Ans²+6-(-1)^Ans(Ans²-2`

It isn't as elegant, but it does produce triples :P However, an even less elegant program would just do:

` ``randInt(1,99 {2Ans,Ans²-1,Ans²+1`

Your version is the one that produces all of the triples, I believe, plus it is smaller :)

]]>` ``PROGRAM:RNDPYTH :ClrDraw :randInt(1,20→X :randInt(X,30→Y :X²+2XY+2Y² :Text(‾1,0,0,Ans-2Y²,"²+",Ans-X²,"²=",Ans,"²`

For any optimizations or suggestions, please reply.

Edit: Error in code now fixed.

]]>