There is a simple formula that gives all the Pythagorean triples.

Suppose that *m* and *n* are two positive integers, with *m* < *n*. Then *n*^{2} – *m*^{2}, 2*mn*, and *n*^{2} + *m*^{2} is a Pythagorean triple.

It’s easy to check algebraically that the sum of the squares of the first two is the same as the square of the last one.

Here are the first few triples for *m* and *n* between 1 and 10. You can also extend for numbers greater than 10.

| m= 1 2 3 4 5 6 7 8 9 ---+------------------------------------------------------------------------------------------------------------------ n= | 2 | [3,4,5] | 3 | [8,6,10] [5,12,13] | 4 | [15,8,17] [12,16,20] [7,24,25] | 5 | [24,10,26] [21,20,29] [16,30,34] [9,40,41] | 6 | [35,12,37] [32,24,40] [27,36,45] [20,48,52] [11,60,61] | 7 | [48,14,50] [45,28,53] [40,42,58] [33,56,65] [24,70,74] [13,84,85] | 8 | [63,16,65] [60,32,68] [55,48,73] [48,64,80] [39,80,89] [28,96,100] [15,112,113] | 9 | [80,18,82] [77,36,85] [72,54,90] [65,72,97] [56,90,106] [45,108,117] [32,126,130] [17,144,145] | 10 | [99,20,101] [96,40,104] [91,60,109] [84,80,116] [75,100,125] [64,120,136] [51,140,149] [36,160,164] [19,180,181]