# finding a Pythagorean triple of a given size

**URL:** <https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335>\
**Category:** Factual Questions\
**Created:** [January 22, 2012, 10:01pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335 "2012-01-22T22:01:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [January 22, 2012, 10:01pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/1 "2012-01-22T22:01:43Z")

</div>

Pythagorean triples are any whole numbers that meet the famous formula A²+B²=C². I’d like to be able to find an example where C is close to but not over a certain value; let’s say 1000 for example. Ideally it should also be “primitive”- that is, it doesn’t factor into a smaller example like 600²+800²=1000² does, and for larger values confirming that there aren’t any common denominators is a problem. I’m aware of how Pythagorean triples can be generated by a set of formulas but I don’t know how to work the process backward from a given end.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [January 22, 2012, 10:43pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/2 "2012-01-22T22:43:23Z")

</div>

Do you care at all about the shape of the triangle? The simplest family of primitive Pythagorean triples gives you really long, skinny triangles. For every odd integer n, there’s a triple with n as the short side, and with the other two sides being separated by 1: For instance, 3, 4, 5; 5, 12, 13; 7, 24, 25; 9, 40, 41; and so forth. In each of these cases, if the short side is n, the other two sides are (n^2-1)/2 and (n^2+1)/2. If we want to find such a triple with the long side close to but not over 1000, then we take the equation 1000 = (n^2+1)/2 , or rearranging to solve for n, n = sqrt(2\*1000 - 1) = sqrt(1999). The square root of 1999 is 44.71… . Rounding down to the next odd number, that gives us 43, so our triple is 43, 924, 925 .

All that said, though, there are plenty of primitive Pythagorean triples that _don’t_ fall into that family, too, and one of those might be closer to 1000 (in fact, I’d be surprised if there weren’t).

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [January 22, 2012, 11:06pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/3 "2012-01-22T23:06:47Z")

</div>

The hypotenuse will be a[sup]2[/sup]+b[sup]2[/sup] in the usual parametric form. You can try all cases to find the closest to 1000; it is 31[sup]2[/sup] + 6[sup]2[/sup] = 997

The other sides of the right triangle are a[sup]2[/sup]-b[sup]2[/sup] and 2ab, and a=31, b=6, so  
(997, 925, 372)

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [January 22, 2012, 11:10pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/4 "2012-01-22T23:10:31Z")

</div>

> [@Lumpy](#):
>
> Pythagorean triples are any whole numbers that meet the famous formula A²+B²=C². I’d like to be able to find an example where C is close to but not over a certain value; let’s say 1000 for example. Ideally it should also be “primitive”- that is, it doesn’t factor into a smaller example like 600²+800²=1000² does, and for larger values confirming that there aren’t any common denominators is a problem. I’m aware of how Pythagorean triples can be generated by a set of formulas but I don’t know how to work the process backward from a given end.

A few years ago I was thinking about this kind of thing: I was particularly interested in a couple of things: how to generate Pythagorean triples with some rule, and whether I could find a triple where all the integers were relatively prime (having no common factor) and which the difference between b and c was an integer other than 1 (the most commonly mentioned Pythagorean triples are 3-4-5 and 5-12-13, both of which have a difference of 1 between b and c - it’s easy enough to make an arbitrary integer difference between b and c by multiplying creating a’=k_a, b’=k_b, and c’=k\*c, but then the triple is not a “primitive triple” since the integers share a common factor (note that I’m only interested in positive integers in this case).

```
        Here's how I reasoned. Let d be the difference between b and c - c=b+d. Then, a*a=(b+d)*(b+d)-b*b, or a*a=d*(2b+d). If d=1, then b=(a*a-1)/2; for any odd a, you can create a Pythagorean triple; for a=1 we get the degenerate case of 1-0-0, but a=3 gives 3-4-5, a=5 gives 5-12-13, a=7 gives 7-24-25, and so on.

        For d=2, a*a=2*(2*b+2), or b=(a*a-4)/4. For any even a, you can create a Pythagorean triple; for a=2, again we get a degenerate case (2-0-2), but for a=4, we get 4-3-5 (again!), for a=6, we get 6-8-10 (not a primitive triple - all the integers are divisible by 2), for a=8, we get 8-15-17, for a=10, we get 10-24-26 (another non-primitive), and so on (for a divisible by 2 but not by 4, you get a non-primitive triple, for a divisible by 4 you get a primitive triple).

        What happens when d is greater than 2? a*a still needs to equal d*(2b+d), so a*a must be divisible by d. Since a*a is a perfect square, (2b+d) must also be divisible by d, which means that b must be divisible by d. Since c*c=a*a+b*b, c must also be divisible by d. Therefore, every Pythagorean triple with d&gt;2 is not primitive. QED.

```

---

<div class="post-metadata">

**Author:** ![Thudlow\_Boink](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thudlow_boink/32/320_2.png) [@Thudlow\_Boink](https://boards.straightdope.com/u/Thudlow_Boink)\
**Post date:** [January 22, 2012, 11:11pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/5 "2012-01-22T23:11:15Z")

</div>

You could consult a [list of Pythagorean triples](http://www.tsm-resources.com/alists/trip.html) that’s sorted by c.

---

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [January 23, 2012, 1:24am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/6 "2012-01-23T01:24:16Z")

</div>

Here’s where I’m coming from: at one point I thought that all Pythagorean triples were of the skinnier and skinnier triangles type, where B and C differ by either one or two. Then I learned about Euclid’s Formula, which allows you to generate triples by taking two numbers M and N, where A=M²-N², B=2MN, and C=M²+N². I then learned of counter-examples to the skinny triangles types, especially 20²+21²=29², the next triple after 3-4-5 where A and B differ by one.

The triples where A and B differ by one are based on the values of M and N for a series sometimes called the “Silver Ratio” by analogy with the Golden Ratio, where each term after 2 is double the previous term plus the term before that: 1,2,5,12,29, etc. I decided for a lark to see what was the largest such triple that I could verify the full integer value of C² using Windows Calculator, which can handle 31 digits before going into floating-point values. I came up with a ridiculously huge value of C², roughly 3 x 10[sup]30[/sup].

For the next largest Silver Ratio triple C² would be over 31 digits and thus calculated only approximately in floating point mode. However there could still be a verifiable triple where C² is close to 9 x 10[sup]30[/sup] that would trump the example I came up with. But finding it by trial and error would be impossible; one would have to find a proof or formula that generated it.

For the obsessive-compulsive, the values I came up with:[spoiler]  
M= 38,613,965  
N= 15,994,428  
A=M²-N²= 1,235,216,565,974,041  
B=2MN= 1,235,216,565,974,040  
C=M²+N²= 1,746,860,020,068,409

A²= 1,525,759,964,856,702,382,327,085,869,681  
B²= 1,525,759,964,856,699,911,893,953,921,600  
(A²+B²)=C²= (calculated separately and compared):  
3,051,519,929,713,402,294,221,039,791,281  
[/spoiler]

---

<div class="post-metadata">

**Author:** ![rowrrbazzle](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rowrrbazzle/32/414_2.png) [@rowrrbazzle](https://boards.straightdope.com/u/rowrrbazzle)\
**Post date:** [January 23, 2012, 6:23am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/7 "2012-01-23T06:23:19Z")

</div>

This book has a whole chapter (complete on Google Books) on Pythagorean triples which may be helpful. [Recreations in the Theory of Numbers (chapter 14, The Eternal Triangle)](http://books.google.com/books?id=fJTifbYNOzUC&lpg=PP1&pg=PA104#v=onepage&q=eternal%20triangle&f=false)

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 23, 2012, 7:55am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/8 "2012-01-23T07:55:01Z")

</div>

> [@Andy\_L](#):
>
> Since a_a is a perfect square, (2b+d) must also be divisible by d, which means that b must be divisible by d. Since c_c=a_a+b_b, c must also be divisible by d. Therefore, every Pythagorean triple with d\>2 is not primitive. QED.

Your proof looked pretty good until this line. The problem is that d could contain a perfect square, and then (2b+d) must only divide the remaining factors. Take Lumpy’s example of 20²+21²=29²: d is 8, or 2_2_2. (2b+d) is 50, and does not divide 8, but does divide 2 (which is what remains after removing 2\*2 from d).

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [January 23, 2012, 11:34am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/9 "2012-01-23T11:34:51Z")

</div>

> [@Dr.Strangelove](#):
>
> Your proof looked pretty good until this line. The problem is that d could contain a perfect square, and then (2b+d) must only divide the remaining factors. Take Lumpy’s example of 20²+21²=29²: d is 8, or 2_2_2. (2b+d) is 50, and does not divide 8, but does divide 2 (which is what remains after removing 2\*2 from d).

Yeah, I realized my mistake when I saw Lumpy’s example. So close…

---

<div class="post-metadata">

**Author:** ![CalMeacham](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/calmeacham/32/35_2.png) [@CalMeacham](https://boards.straightdope.com/u/CalMeacham)\
**Post date:** [January 23, 2012, 12:30pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/10 "2012-01-23T12:30:24Z")

</div>

> [@Lumpy](#):
>
> Here’s where I’m coming from: at one point I thought that all Pythagorean triples were of the skinnier and skinnier triangles type, where B and C differ by either one or two. Then I learned about Euclid’s Formula, which allows you to generate triples by taking two numbers M and N, where A=M²-N², B=2MN, and C=M²+N². I then learned of counter-examples to the skinny triangles types, especially 20²+21²=29², the next triple after 3-4-5 where A and B differ by one.
> 
> The triples where A and B differ by one are based on the values of M and N for a series sometimes called the “Silver Ratio” by analogy with the Golden Ratio, where each term after 2 is double the previous term plus the term before that: 1,2,5,12,29, etc. I decided for a lark to see what was the largest such triple that I could verify the full integer value of C² using Windows Calculator, which can handle 31 digits before going into floating-point values. I came up with a ridiculously huge value of C², roughly 3 x 10[sup]30[/sup].
> 
> For the next largest Silver Ratio triple C² would be over 31 digits and thus calculated only approximately in floating point mode. However there could still be a verifiable triple where C² is close to 9 x 10[sup]30[/sup] that would trump the example I came up with. But finding it by trial and error would be impossible; one would have to find a proof or formula that generated it.
> 
> For the obsessive-compulsive, the values I came up with:[spoiler]  
> M= 38,613,965  
> N= 15,994,428  
> A=M²-N²= 1,235,216,565,974,041  
> B=2MN= 1,235,216,565,974,040  
> C=M²+N²= 1,746,860,020,068,409
> 
> A²= 1,525,759,964,856,702,382,327,085,869,681  
> B²= 1,525,759,964,856,699,911,893,953,921,600  
> (A²+B²)=C²= (calculated separately and compared):  
> 3,051,519,929,713,402,294,221,039,791,281  
> [/spoiler]

If you’re looking for Pythagorean Triples where one leg and the hyponteneuise differ by one, then you should know that every odd number is the short leg in such a puthagorean triple. If that short leg is **2 n + 1** , then the other side is \*\*2 n [sup]2[/sup] + 2 n \*\* and the hypoteneuse is, predictably, **2 n [sup]2[/sup] + 2 n + 1**. (And the radius of the inscribed circle is simply **n** ).

It’s true that you can thus generate more and more unique, non-divisible Pythagorean Triples in this fashion, but that doesn’t mean that _all_ further non-divisible Pythagorean triples are of this form, as you can verify by playing with Euclid’s formula. In addition, that very useful formula will not generate all possible Pythagoream triples. You can easily verify, by plugging in numbers, that it skips some of the multiples of lower-order triples. I don’t know if it generates all lowest order triples, but I suspect it doesn’t.

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [January 23, 2012, 6:17pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/11 "2012-01-23T18:17:59Z")

</div>

> [@Lumpy](#):
>
> Pythagorean triples are any whole numbers that meet the famous formula A²+B²=C². I’d like to be able to find an example where C is close to but not over a certain value; let’s say 1000 for example. Ideally it should also be “primitive”- that is, it doesn’t factor into a smaller example like 600²+800²=1000² does, and for larger values confirming that there aren’t any common denominators is a problem. I’m aware of how Pythagorean triples can be generated by a set of formulas but I don’t know how to work the process backward from a given end.

Euclid’s formula tells you that for a primitive Pythagorean triple, the hypotenuse c is a sum of two squares, c=m[sup]2[/sup]+n[sup]2[/sup]. Your question (I think) is, _What constraints does this place on c; and how can I find m and n given c?_

The answer to the first question (which integer values can be hypotenuses of primitive Pythagorean triangles) is given by Fermat’s theorem on the sum of two squares:

> [@](#):
>
> **Fermat’s theorem on sums of two squares:**  
> An odd prime p can be written (uniquely) as the sum of two squares if and only if p==1 (mod 4).

The “only if” part is obvious: squares are either 0 or 1 (mod 4), so the sum of two squares cannot be 3 (mod 4)–the important part is the “if” statement. There’s also an algorithm (Cornacchia’s algorithm) for finding m and n more efficiently than the O(sqrt(c)) exhaustive search.

With Fermat’s theorem together with an equation which goes by the impressive name of the “Brahmagupta-Fibonacci identity”

> [@](#):
>
> **Brahmagupta-Fibonacci identity:**  
> (a[sup]2[/sup]+b[sup]2[/sup])(c[sup]2[/sup]+d[sup]2[/sup])=(ac+bd)[sup]2[/sup]+(ad-bc)[sup]2[/sup]

(this identity, btw, looks amazing when first encountered; but when looked at in the right way, as a statement about complex numbers, it is trivial) you can prove that you can write a number c as the sum of two squares (and so use it as the hypotenuse of a primitive Pythagorean triple) if and only if, in the prime factorization of c, each odd prime factor congruent to 3 (mod 4) occurs to an even power. The idea is to write each 1-mod-4 prime in the squarefree part of c as a sum of squares (by Fermat) and then combine these factors using Brahmagupta-Fibonacci.

For example, take c=3_3_5_13=585. We have 5=2[sup]2[/sup]+1[sup]2[/sup] and 13=3[sup]2[/sup]+2[sup]2[/sup] for the two 1-mod-4 factors of c. Using BF gives us  
5_13=(2[sup]2[/sup]+1[sup]2[/sup])_(3[sup]2[/sup]+2[sup]2[/sup])=8[sup]2[/sup]+1[sup]2[/sup]=7[sup]2[/sup]+4[sup]2[/sup],  
and then multiplying by the square root of the square factor of c gives  
c=(3_8)[sup]2[/sup]+(3_1)[sup]2[/sup]=24[sup]2[/sup]+3[sup]2[/sup]  
and  
c=(3_7)[sup]2[/sup]+(3_4)[sup]2[/sup]=21[sup]2[/sup]+12[sup]2[/sup].  
For your example of c~1000, you can just look in the neighborhood of 1000 for appropriate values. 999, 995, 991, … are all 3 (mod 4) so they’re out; but 997 is prime and 1 (mod 4) so it would work (997=31[sup]2[/sup]+6[sup]2[/sup]). 993 has a single factor of 3 so it’s out; likewise 989 is out; but 985=5_197 and 981=3_3_109, so they would also work (though 981 wouldn’t give a primitive triple, since m and n would share a factor of 3).

So as long as you can factor c, it’s easy to determine whether it can be the hypotenuse of a primitive Pythagorean triangle:

> [@](#):
>
> **Just tell me the answer already:**  
> c is the hypotenuse of a primitive Pythagorean triangle iff it’s of the form c=(product of 3-mod-4 primes)[sup]2[/sup] \* (product of 1-mod-4 primes).

And of course if you don’t demand primitivity, you can factor out all of the offending 3-mod-4 factors to give a smaller triangle, as long as there’s at least one 1-mod-4 factor left to use to make a triangle with.

Factoring c, if you are not constructing c explicitly by multiplying primes, will eventually get difficult; but at the sizes c~10[sup]15[/sup] you’re interested in, factoring is still easy to do by exhaustive search.

> [@CalMeacham](#):
>
> It’s true that you can thus generate more and more unique, non-divisible Pythagorean Triples in this fashion, but that doesn’t mean that _all_ further non-divisible Pythagorean triples are of this form, as you can verify by playing with Euclid’s formula. In addition, that very useful formula will not generate all possible Pythagoream triples. You can easily verify, by plugging in numbers, that it skips some of the multiples of lower-order triples. I don’t know if it generates all lowest order triples, but I suspect it doesn’t.

Euclid’s formula (m[sup]2[/sup]-n[sup]2[/sup],2mn,m[sup]2[/sup]+n[sup]2[/sup]) actually does generate all and precisely the _primitive_ Pythagorean triples, when m and n are chosen with m\>n, m+n odd, and m and n relatively prime. To get the nonprimitive triangles you just consider all multiples of the primitive triangles, (k(m[sup]2[/sup]-n[sup]2[/sup]),2kmn,k(m[sup]2[/sup]+n[sup]2[/sup])).

---

<div class="post-metadata">

**Author:** ![CalMeacham](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/calmeacham/32/35_2.png) [@CalMeacham](https://boards.straightdope.com/u/CalMeacham)\
**Post date:** [January 23, 2012, 7:34pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/12 "2012-01-23T19:34:10Z")

</div>

> [@](#):
>
> Euclid’s formula (m2-n2,2mn,m2+n2) actually does generate all and precisely the primitive Pythagorean triples, when m and n are chosen with m\>n, m+n odd, and m and n relatively prime. To get the nonprimitive triangles you just consider all multiples of the primitive triangles, (k(m2-n2),2kmn,k(m2+n2)).

But , as I said, it doesn’t generate all the non-priomitive ones. It does generate most of the non-primitive ones, but there are curious gaps.

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [January 23, 2012, 8:53pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/13 "2012-01-23T20:53:22Z")

</div>

> [@CalMeacham](#):
>
> But , as I said, it doesn’t generate all the non-priomitive ones. It does generate most of the non-primitive ones, but there are curious gaps.

I was responding to your suspicion that Euclid’s formula doesn’t generate all of the primitive triples.

If you remove the restrictions on relative primality (i.e., require only m\>n) then Euclid’s formula does generate some nonprimitive triples, but not really most of them except for small common factors: in fact it generates only the triples which are either a square multiple or twice a square multiple of the primitive triples (i.e., k=1, 2, 4, 8, 9, 16, 18, 25, 32, …). So it generates (3,4,5) and (6,8,10) but not (9,12,15); then it gets (12,16,20) but misses (15,20,25), (18,24,30), and (21,28,35); and so on.

> [@Lumpy](#):
>
> I decided for a lark to see what was the largest such triple that I could verify the full integer value of C² using Windows Calculator, which can handle 31 digits before going into floating-point values. I came up with a ridiculously huge value of C², roughly 3 x 10[sup]30[/sup].

For what it’s worth, recent versions of the Windows Calculator actually use more precision than this internally; it’s just the display that is limited to 31-or-whatever digits. (Wiki says it’s using arbitrary-precision arithmetic; I don’t know what limits it has, but it seems to be substantially more than 31 digits.)

---

<div class="post-metadata">

**Author:** ![Blakeyrat](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Blakeyrat](https://boards.straightdope.com/u/Blakeyrat)\
**Post date:** [January 23, 2012, 11:35pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/14 "2012-01-23T23:35:51Z")

</div>

> [@Omphaloskeptic](#):
>
> For what it’s worth, recent versions of the Windows Calculator actually use more precision than this internally; it’s just the display that is limited to 31-or-whatever digits. (Wiki says it’s using arbitrary-precision arithmetic; I don’t know what limits it has, but it seems to be substantially more than 31 digits.)

I can’t speak for Windows Calculator specifically, but generally “arbitrary-precision” is limited only by available memory in the machine and the user’s patience while waiting for the answer.

---

<div class="post-metadata">

**Author:** ![CalMeacham](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/calmeacham/32/35_2.png) [@CalMeacham](https://boards.straightdope.com/u/CalMeacham)\
**Post date:** [January 23, 2012, 11:45pm UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/15 "2012-01-23T23:45:26Z")

</div>

> [@](#):
>
> I was responding to your suspicion that Euclid’s formula doesn’t generate all of the primitive triples.

You declare that, but is it true? I’ve never seen a proof of it. certainly it’s worked as far as I’ve taken it, but that’ not a proof.

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 24, 2012, 12:45am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/16 "2012-01-24T00:45:06Z")

</div>

> [@Omphaloskeptic](#):
>
> but 985=5_197 and 981=3_3\*109, so they would also work (though 981 wouldn’t give a primitive triple, since m and n would share a factor of 3).

I wrote a little program to generate this table of numbers with (b-a)=1:  
a=3, b=4, c=5  
a=20, b=21, c=29  
a=119, b=120, c=169  
a=696, b=697, c=985  
a=4059, b=4060, c=5741  
a=23660, b=23661, c=33461  
a=137903, b=137904, c=195025  
a=803760, b=803761, c=1136689  
a=4684659, b=4684660, c=6625109  
a=27304196, b=27304197, c=38613965

Obviously, the ratios here are all close to sqrt(2), and coincidentally one of them has the hypotenuse 985 that you mentioned.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [January 24, 2012, 12:54am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/17 "2012-01-24T00:54:58Z")

</div>

> [@Andy\_L](#):
>
> Yeah, I realized my mistake when I saw Lumpy’s example. So close…

If Euclid’s formula generates all primitive triplets, I can show that there is a restriction on the differences (c-a) and (c-b): for all primitive triplets, the difference is either a perfect square or 2 times a perfect square. That makes me feel a little better (I had thought there (c-a) and (c-b) couldn’t equal 3 in a primitive triplet, though my proof to show that went astray)

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 24, 2012, 12:55am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/18 "2012-01-24T00:55:12Z")

</div>

> [@Dr.Strangelove](#):
>
> I wrote a little program to generate this table of numbers with (b-a)=1:

Sorry to stray a bit off-topic, but I just noticed that the ratio between successive a’s seems to converge on a constant:  
6.6666666666666670  
5.9500000000000002  
5.8487394957983190  
5.8318965517241379  
5.8290219265829020  
5.8285291631445482  
5.8284446313713261  
5.8284301283965361  
5.8284276400907729

Anyone know if this constant has a name?

---

<div class="post-metadata">

**Author:** ![Dr.Strangelove](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dr.strangelove/32/6613_2.png) [@Dr.Strangelove](https://boards.straightdope.com/u/Dr.Strangelove)\
**Post date:** [January 24, 2012, 1:11am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/19 "2012-01-24T01:11:14Z")

</div>

> [@Dr.Strangelove](#):
>
> Anyone know if this constant has a name?

Looks like the sequence is [known](http://oeis.org/A001653), and the ratio is 3+sqrt(8). It does make it fairly easy to generate new triples with nearly-equal a and b.

---

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [January 24, 2012, 2:10am UTC](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335/20 "2012-01-24T02:10:02Z")

</div>

> [@Dr.Strangelove](#):
>
> Sorry to stray a bit off-topic, but I just noticed that the ratio between successive a’s seems to converge on a constant:  
> 6.6666666666666670  
> 5.9500000000000002  
> 5.8487394957983190  
> 5.8318965517241379  
> 5.8290219265829020  
> 5.8285291631445482  
> 5.8284446313713261  
> 5.8284301283965361  
> 5.8284276400907729
> 
> Anyone know if this constant has a name?\<snip\>Looks like the sequence is [known](http://oeis.org/A001653), and the ratio is 3+sqrt(8).

Or more preciesely, it’s converging on (√2+1)², which is a natural consequence of how the sequence is defined. If we’re looking for triples where A and B are as close to equal as possible (differing only by one), and A=M²-N² and B=2MN, then taking A and B as exactly equal as a limit you start with M²-N²=2MN. If you take N as 1 then the equation successively becomes:  
M²-1=2M,  
M²-2M-1=0  
M²-2m+1=2  
(M-1)²=2  
M-1=√2  
M=√2+1

So for M and N you have the sequence of 1,2,5,12,29,… where each new term is about (√2+1\*\*) \*\*x the previous term. This is equivalent to the rule where each term is equal to double the previous term plus the one before that because each term is then about (√2+1)² x the term two places back, which is 2+2√2+1, then 2(√2+1)+1, when the term two places back is taken as 1.

So using that sequence to define each new A means the ratio of the A’s converges on (√2+1)²

[Next page](https://boards.straightdope.com/t/finding-a-pythagorean-triple-of-a-given-size/610335.md?page=2)
