# Generating primitive Pythagorean triples

Given this equation $$a^2 + b^2 = c^2$$ , in order to generate all primitive Pythagorean triples all we nedd to do is : write (a,b,c) as :

$$a = 2mn$$

$$b = m^2-n^2$$

$$c= m^2+n^2$$

with conditions : $$\gcd(m,n)=1$$ and $$(m+n)$$%$$2= 1$$

But what about if we add a parameter $$K$$ to the equation such that : $$a^2 + b^2 = c^2 - K$$ , with $$K$$ being a positive integer , how can we generate $$(a,b,c)$$ in this case satisfying the equation above such that $$\gcd(a,b,c) =1$$ ?

• What does "primitive" mean in this context? For Pythagorean triples. ,if $(a,b,c)$ satisfies $a^2+b^2=c^2$ then $(\lambda a, \lambda b, \lambda c)$ satisfies $(\lambda a)^2+(\lambda b)^2=(\lambda c)^2$ but no such statement is true for your new equation.
– lulu
Oct 18, 2020 at 12:15
• Every non-primitive pythagorean triple is a multiple of a primitive pythogorean triple. So, if we know the primitive ones, we basically know them all. $a^2+b^2=c^2-k$ is something completely different. Oct 18, 2020 at 12:21
• What do you meant by $(m+n)$%$2= 1$? Oct 19, 2020 at 17:41

We need only show how side $$C$$ of one triple is the same as side $$A$$ of another triple. For example, if we have $$(3,4,5)$$ and $$(5,12,13)$$, then
$$A_1^2+B_1^2=C_2^2-K_2^2\quad\text{ is simply }\quad 3^2+4^2=13^2-12^2$$ In this "easiest" case, $$GCD(A_1,B_1,C_2)=1$$.
There is a formula to identify these matches, if they exist. Let us begin with $$(33,56,65)\text{ and }(63,16,65)\quad$$ and find matches where $$A_2=C_1=65$$.
$$\begin{equation} A=m^2-n^2\implies n=\sqrt{m^2-A}\qquad\text{for}\qquad \sqrt{A+1} \le m \le \frac{A+1}{2} \end{equation}$$ $$A=65\implies \lfloor\sqrt{65+1}\rfloor=8\le m \le \frac{65+1}{2} =33\quad\land\quad m\in\{9,33\}\implies n \in\{4,32\}$$ $$F(9,4)=(65,72,97)\qquad \qquad F(33,32)=(65,2112,2113)$$
What this means is $$(33^2+56^2)=(63^2+16^2)=(97^2-72^2)=(2113^1-2112^2)$$
There are an infinite number of these because side $$A$$ includes any odd number greater than $$1$$. Also, I haven't proven it yet but all of the examples I have seen have shown that the $$GCD(A,B,C)=1$$ requirement is also met.