This page is divided into the following sections:
If you are looking for a way to generated triples there is a calculator in the "Algorithms" section.
Pythagorean triples are sets of three integers (a,b,c) where a^2 + b^2 = c^2. The simplest of these (where 'a', 'b' and 'c' are all greater than 0) is (3,4,5) as 9 + 16 = 25. There are clearly an unlimited number of these triples as any multiple of (3,4,5), say (33,44,55), also meets the requirements: (1089 + 1936 = 3025).
Ignoring these multiples, how many of these triples are there?
![]() |
The image on the left is constructed by taking the first two terms (a and b) an plotting them on squared paper. In this chart the 'c' value is now the distance of the points from the origin (the centre). Light blue points represent those values of 'a' and 'b' that have no common factors. There are basically five of these - (3,4), (5,12), (7,24), (8,15) and (20, 21) - with c values of (5,13,25,17 and 29). The 8 fold symmetry and the other 35 light blue points arise because if a^2 + b^2 = c^2 is true for (a,b) it is also true for (b,a), (−b,a), (−a,−b) etc. The darker blue points represent the multiples of the basic points, (6,8), (9,12), (10,24) etc. Note: the images on this page omit the triple (0,0,0) and all the multiples and permutations of (0,1,1). |
I will call the triples where 'a' and 'b' have no common factors and b > a > 0 the prime triples. So how many prime triples are there? The next image shows all the triples (prime or otherwise) out to (320,320).

The prime ones are shown in light blue and their multiples darker. Each prime triple generates a line of evenly spaced multiples, which are shown in darker blue. The really obvious lines are generated by variations of (3,4). There are 57 prime triples in this diagram, repeated 8 times through reflection and permutation. They are:
| (3, 4, 5) | (8, 15, 17) | (60, 221, 229) | (65, 72, 97) | (175, 288, 337) |
| (5, 12, 13) | (12, 35, 37) | (68, 285, 293) | (85, 132, 157) | (140, 171, 221) |
| (7, 24, 25) | (16, 63, 65) | (33, 56, 65) | (95, 168, 193) | (160, 231, 281) |
| (9, 40, 41) | (20, 99, 101) | (39, 80, 89) | (105, 208, 233) | (180, 299, 349) |
| (11, 60, 61) | (24, 143, 145) | (51, 140, 149) | (115, 252, 277) | (204, 253, 325) |
| (13, 84, 85) | (28, 195, 197) | (57, 176, 185) | (88, 105, 137) | (207, 224, 305) |
| (15, 112, 113) | (32, 255, 257) | (69, 260, 269) | (104, 153, 185) | (225, 272, 353) |
| (17, 144, 145) | (20, 21, 29) | (75, 308, 317) | (120, 209, 241) | (252, 275, 373) |
| (19, 180, 181) | (28, 45, 53) | (48, 55, 73) | (136, 273, 305) | (297, 304, 425) |
| (21, 220, 221) | (36, 77, 85) | (60, 91, 109) | (119, 120, 169) | |
| (23, 264, 265) | (44, 117, 125) | (84, 187, 205) | (133, 156, 205) | |
| (25, 312, 313) | (52, 165, 173) | (96, 247, 265) | (161, 240, 289) |
Table 1.
The simplest way to generate a sequence of triples is to notice that difference between consecutive square numbers [1,4,9,16,...] generates the sequence of odd numbers [3,5,7,9,...]. If the odd number is also a square [9,25,49,...] you have a triple. And because two consecutive square numbers can't have any common factors it must be prime. So we have already found a mechanism for generating an unlimited number of prime triples. The numbers in the first column of the table 1 (above) belong to this sequence. We can create a generic formula for these triples as follows:
a^2+b^2=(b+1)^2
{IMP}a^2+b^2=b^2+2b+1
{IMP}a^2=2b+1
(substitute a=2k+1)
{IMP}(2k+1)^2=2b+1
{IMP}4*k^2+4*k+1=2b+1
{IMP}2*k^2+2*k=b
a=2*k+1
b=2*k*(k+1)
c=2*k*(k+1)+1
Although the above algorithm generates an unending sequence of prime triples it doesn't generate them all. Of the 57 prime triples in table 1, only 12 follow this pattern.
Starting with c = b + n, where n is a positive integer;
a^2+b^2=(b+n)^2
{IMP}a^2+b^2=b^2+2nb+n^2
{IMP}a^2=2nb+n^2
{IMP}a^2=n*(2b+n)
So n*(2b+n) must be a square number.
To find solutons to this equation we look at the prime factors of n and (2b + n), starting with n. Some prime factors will appear an odd number of times and others an even number. We collect all the even ones into one list and all the odd ones into another. If a prime factor appears an odd number of times more than 2, then one goes into the odd list and the remainder into the even list.
The product off all the even factors will be a square number and the product off all the odd ones will have no repeated prime factors. This is a rather long winded way of demonstrating that all integers can be factorised into the product of a square and a term with no repeating factors, so long as we allow the posibility that the square number is 1.
n = x^2*k
For n*(2b+n) to be a square number, (2b + n) must be the product of 'k' and another square number y^2). So
a^2 = n*(2b + n) = (x^2*k)*(k*y^2) = (x*k*y)^2 Giving: a=x*k*y b=(y^2-x^2)*(k/2) c=b + n =(y^2-x^2)*(k/2) + x^2*k =(y^2 + x^2)*(k/2)
Where 'x', 'y' and 'k' are all integers. When 'n' is even, another factorisation is possible:
n =2m a^2=2m*(2b+2m)=4m*(b+m) Set m =k*x^2 b+m=k*y^2 Giving: a=2*x*k*y b=k*(y^2-x^2) c=k*(y^2+x^2)
In the interactive element above, if you set y = (1+√2)x (or as close as you can get), the 'a' and 'b' values will be similar.
When 'n' is 1, 'x' is 1 and 'k' is 1. So
a=y b=(y^2-1)/2 c=(y^2+1)/2
For integer solutions y must be odd (1,3,5,...). This generates the triples [1,0,1], [3,4,5], [5,12,13], etc.
When 'n' is 2 we use the second factorisation based on, n = 2m. So 'x' is 1 and 'k' is 1, giving;
a=2*x*k*y=2*y b=k*(y^2-x^2)=(y^2-1) c=k*(y^2+x^2)=(y^2+1)
This generates the sequence
[ 2, 0, 2] [ 4, 3, 5] = [3, 4, 5] [ 6, 8, 10] = 2*[3, 4, 5] [ 8, 15, 17] [10, 24, 26] = 2*[5, 12, 13] [12, 35, 37] [14, 48, 50] = 2*[7, 24, 25] [16, 63, 65] [18, 80, 82] = 2*[9, 40, 41] [20, 99, 101]
When 'y' is odd, y^2±1 is even and all the terms can be divided by 2, so this formulation only generates prime triples when 'y' is even, making 'a' is a multiple of 4. Eliminating the permutation of (3,4,5), multiples of (0,1,1) and other multiples leaves the prime sequence:
[ 8, 15, 17] [12, 35, 37] [16, 63, 65] [20, 99, 101] ...
For n = 3 we use the original formulation where k = 3 and x = 1.
a=x*k*y=3*y b=(y^2-x^2)*(k/2)=(y^2-1)*(3/2) c=(y^2+1)*(3/2)
'a', 'b' and 'c' are all divisible by 3 so all triples generated are multiples of those generated by n = 1. In general when k > 1 'a', 'b' and 'c' will have 'k' as a common factor so the triple can't be prime.
Above we identified two sets of equations
| a: | x*k*y | 2*x*k*y |
| b: | (y^2-x^2)*(k/2) | k*(y^2-x^2) |
| c: | (y^2+x^2)*(k/2) | k*(y^2+x^2) |
The equations in the second column are equivalent to the ones in the first column, when k is even. For instance setting k=2 in the first column generates the same triple as k=1 in the second. So we can generate all triples using just the first set of equations. All the prime triples can generated using k values of 1 or 2. When k is odd x^2-y^2 must be even.
A plot of the prime triples out to (3200x3200). Each pixel represents a 10x10 cell. This is quite interesting as most of the points appear to lie on curves and there are 'special' points where three of these curves appear to intersect.
![]() |
The same area with the non prime triples (red) included. The straight lines are generated by multiples of the smaller triples like (3,4,5).
![]() |
And finally the prime triples shown out to (32000,32000). Each pixel now represents 100x100 points.
![]() |
The (a, b) values from the following set of triples appear to lie on a curve. They can be divided into two sub sets bases on whether 'a' is odd or even:
| Even | Odd | Image |
|---|---|---|
|
−616^2 + 663^2 = 905^2 −540^2 + 629^2 = 829^2 −468^2 + 595^2 = 757^2 −400^2 + 561^2 = 689^2 −336^2 + 527^2 = 625^2 −276^2 + 493^2 = 565^2 −220^2 + 459^2 = 509^2 −168^2 + 425^2 = 457^2 −120^2 + 391^2 = 409^2 −76^2 + 357^2 = 365^2 −36^2 + 323^2 = 325^2 32^2 + 255^2 = 257^2 60^2 + 221^2 = 229^2 84^2 + 187^2 = 205^2 104^2 + 153^2 = 185^2 120^2 + 119^2 = 169^2 132^2 + 85^2 = 157^2 140^2 + 51^2 = 149^2 144^2 + 17^2 = 145^2 |
−481^2 + 600^2 = 769^2 −385^2 + 552^2 = 673^2 −217^2 + 456^2 = 505^2 −145^2 + 408^2 = 433^2 −25^2 + 312^2 = 313^2 23^2 + 264^2 = 265^2 95^2 + 168^2 = 193^2 119^2 + 120^2 = 169^2 143^2 + 24^2 = 145^2 |
|
These two lists actually define two parabolas that are almost coincident. If we take two points from one of the lists, say (a¬1, b¬1) and (a¬2, b¬2), we can construct the equation:
a = (A + B*b^2) / C, where; B = (a¬1-a¬2) C = (b¬1^2-b¬2^2) A = (C*a¬1-B*b¬1^2)
a neater formulation is
C(a-a¬1)=B(b^2-b¬1^2)
In the above example the points in the left column lie on the curve
b^2+578a-83521=0
and those on the right
These curves intersect the a-axis at 144.5 (17^2/2) and 144 (12^2) respectively. The are nearly co-incident because 17/12 isn't a bad approximation for √2. They are examples of the general curves:
b^2+2m^2a-m^4=0 and b^2+4m^2a-4m^4=0
where 'm' is a positive integer. These can be derived from the generating equations: a=x*k*y and b=(y^2-x^2)*(k/2). Substituting x=a/ky into the second equation gives:
b=(y^2-a^2/k^2y^2)*(k/2).
which can be aranged to give
a^2+(2ky^2)b − k^2y^4=0.
The 2 equations above correspond to the cases where k = 1 and 2, and m = y (a and b have been swapped). There are actually 4 sets of parabolas, the other three are generated through the transformations: (a,b) ⇔ (a,−b), (a,b) ⇔ (b,a) and (a,b) ⇔ (b,−a), representing reflections in the lines a = 0, a = b and a = −b.
This image:
Shows the set of parabolas for k = 1 with the prime triples superimposed. I've called these the 'West' parabolas as they extend infinitely to the left. This shows that about half the prime triples fall on these lines. If we add in the k = 2 parabolas we see that now all the primes are accounted for.
If we add in the "East" parabolas (generated by the transformation (a,b) ⇔ (a,−b)) we get the following image, which shows that all the prime triples lie on the intersection of an East and a West parabola with the same 'k' value (1 or 2).
Interestingly, if we add in the other two sets of parabolas, North and South (generated from (b,a) and (b,−a)) we now see that the triples that were the intersection of 2 East/West parameters are also at the intersection of two North/South parabolas of the opposite k value (1 ⇔ 2).
So we can locate all the prime triples using just one set of parabolas. The intersections that don't have prime triples do have non prime triples.
If we take two complex numbers (a¬1,b¬1) and (a¬2,b¬2) and multiply them together we get a third complex number (a¬3,b¬3). If these numbers are interpreted as vectors then the lengths (l) of the three vectors are related as l¬3 = l¬1 x l¬2. So if (a¬1,b¬1,l¬1) and (a¬2,b¬2,l¬2) are Pythagorean triples so is (a¬3,b¬3,l¬3).
When multiplying complex numbers;
a¬3=a¬1*a¬2-b¬1*b¬2 b¬3=a¬1*b¬2 + b¬1*a¬2
We can use this as another way of generating unlimited series of triples, for instance the powers of (3,4) are;
| (3 + 4i)n = | a | b | c | x | y | k | |
| (3 + 4i)1 | (3 + 4i) | 3 | 4 | 5 | 1 | 3 | 1 |
| (3 + 4i)2 | (-7 + 24i) | 7 | 24 | 25 | 1 | 7 | 1 |
| (3 + 4i)3 | (-117 + 44i) | 44 | 117 | 125 | 2 | 11 | 2 |
| (3 + 4i)4 | (-527 - 336i) | 336 | 527 | 625 | 7 | 24 | 2 |
| (3 + 4i)5 | (-237 - 3116i) | 237 | 3,116 | 3,125 | 3 | 79 | 1 |
| (3 + 4i)6 | (11753 - 10296i) | 10,296 | 11,753 | 15,625 | 44 | 117 | 2 |
| (3 + 4i)7 | (76443 + 16124i) | 16,124 | 76,443 | 78,125 | 29 | 278 | 2 |
| (3 + 4i)8 | (164833 + 354144i) | 164,833 | 354,144 | 390,625 | 191 | 863 | 1 |
| (3 + 4i)9 | (-922077 + 1721764i) | 922,077 | 1,721,764 | 1,953,125 | 481 | 1917 | 1 |
| (3 + 4i)10 | (-9653287 + 1476984i) | 1,476,984 | 9,653,287 | 9,765,625 | 237 | 3116 | 2 |
Although this series is unlimited the examples it generates are rather far apart, only the first six appear in our diagrams above. The 'x', 'y' and 'k' columns shows the values used to generate this triple, using the first set of equations. Notice that all the 'k' values are 1 or 2, so all these triples are prime, according to our original definition. An alternative definition of primeness based on this complex number mutiplication would render all but (3,4,5) composite.
The series generated by (5,12) shoots out of sight even more rapidly.
| a | b | c | x | y | k |
| 5 | 12 | 13 | 1 | 5 | 1 |
| 119 | 120 | 13^2 | 7 | 17 | 1 |
| 828 | 2,035 | 133 | 3 | 138 | 2 |
| 239 | 28,560 | 13^4 | 1 | 239 | 1 |
| 145,668 | 341,525 | 135 | 122 | 1194 | 2 |
| 3,369,960 | 3,455,641 | 136 | 828 | 2035 | 2 |
| 23,161,315 | 58,317,492 | 137 | 2105 | 11003 | 1 |
| 13,651,680 | 815,616,479 | 138 | 239 | 28560 | 2 |
| 4,241,902,555 | 9,719,139,348 | 139 | 29755 | 142561 | 1 |
| 95,420,159,401 | 99,498,527,400 | 1310 | 195857 | 487193 | 1 |
When multiplying two different triples together there are two possible result sets, for instance multiplying the 64 permutations of (3,4,5) and (5,12,13) generates two sets of 32 values based on (16, 63, 65) and (33, 56, 65). For instance;
(3 + 4j) x ( 5 + 12j) = (-33 + 56j) (3 + 4j) x (12 + 5j) = ( 16 + 63j) (4 + 3j) x (12 + 5j) = ( 33 + 56j) (4 + 3j) x ( 5 + 12j) = (-16 + 63j) => 65^2 = 16^2 + 63^2 = 33^2 + 56^2
Generally, if 'c¬1' and 'c¬2' are the largest values in different triples, then c¬1 × c¬2 will be the largest value in two different triples. This rule doesn't work when c¬1 = c¬2 as one of the triples turns out to be (0,c,c).
(c) John Whitehouse 2014 - 2023