Pythagorean Triplets & Prime Factors Read this knowing that I have no mathematics background whatsoever.
I was solving a specific programming problem that required knowledge of Pythagorean triplets, which is something that I hadn't really worked with before. Anyway, I'm curious if there is an existing proof for this:
The Wikipedia article on Pythagorean triplet functions states that for any positive integer greater than $a = 3$, triplets can be generated with the following formulas:
If a is odd: $b = \frac{a^2}{2} - \frac{1}{2}$ and $c = b + 1$
If b is even: $b = \frac{a^2}{4} - 1$ and $c = b + 2$
However, in looking at the output of a Pythagorean triplet generator I created in Ruby, I noticed a pattern which seemed to say that the above functions actually point to a more generic one:
For any positive integer $a$, where $p$ is any prime factor of $a$ greater than $2$:
$$b = \frac{a^2}{2(\frac{a}{p})} - \frac{\frac{a}{p}}{2}$$
and
$$c = b + \frac{a}{p}$$
For example, let's say that $a=99$ and that $p=11$.
$$b = \frac{99^2}{2(\frac{99}{11})} - \frac{\frac{99}{11}}{2} = 540$$
$$c = 540 + \frac{99}{11} = 549$$
Finally:
$$99^2 + 540^2 = 549^2$$
Or with the prime number $a=48611$ and $p=48611$, you end up with:
$$48611^2 + 1181514660^2 = 1181514661^2$$
This would also imply that for any base $a$, there are at least the same number of Pythagorean triplets that there are of prime factors of $a$ greater than 2, and that likewise, any prime number can be the $a$ of only a single pythagorean triplet.
Edit
As @ThomasAndrews pointed out and I realized, $p$ need not be prime.
 A: Your formula does yield "new" triples, but they are not primitive triples, just multiples of the triples that come from the first formula.  Specifically, if $p$ is a factor of $a$, then using the original formula for $p$ yields the triple $(p,\frac{p^2-1}2,\frac{p^2+1}2)$.  Multiplying the triple by $\frac a p$ gives $(a,b,c)$ with $b=\frac{pa-\frac{a}{p}}2$. This is the same as your formula.
Note that the original formula doesn't even necessarily give you a primitive triple when $a$ is even.  For example, when $a=6$, $b=8.$  In general, the formula only gives you a primitive triple for even $a$ when $4|a$.
There is a relationship between prime factorizations of $a$ and the set of primitive triples that contain $a>1$.  Specifically, let $z(n)$ be the number of distinct prime divisors of $n$.  Then, for fixed $a>1$, the number of primitive solutions to $a^2+b^2=c^2$ with $b,c>0$  is $2^{z(a)-1}$ if $a$ is odd or $4|a$, and $0$ otherwise.
This can be seen as a result of the fact that primitive triples can be written as $(u^2-v^2,2uv,u^2+v^2)$ where $(u,v)=1$ and $u,v$ are not both odd.
In any event, the point of the formula you found on Wikipedia was not to be exhaustive, but rather to quickly show that any $a$ can be found in some non-trivial triple $(a,b,c)$.
