I thought I would share the source code for a console32 program to find Primitive Pythagorean Triplets. This is an example of the type of programs I write, which is mostly for my own interest. Be forewarned, I may not have used the best or latest programming techniques; but, these do work. (I did a few test examples by hand and calculator to confirm that the program was working correctly.)
For those that do not know: Pythagorean Triplets are completely integral, (whole number), solutions to the equation x^2 + y^2 = z^2. A primitive triplet is the lowest unique solution. For example: {3,4,5} is the primitive triplet of {6,8,10}, {9,12,15}, {12, 16, 20}, etc., family. All the family members can be divided by an integral value to get {3, 4, 5}. If you were to graph these points on a x,y-grid, the points would lie on the line defined by y = f(x) = 4x / 3. So, the SlopeHi variable refers the slope of the line for {3, 4, 5}. The solution for {4, 3, 5} , while equivalent to {3, 4, 5} in the Pythagorean Theorem, lines on the line y = f(x) = 3x / 4. (SlopeLo variable.) It should be noted that NOT just any line on the x,y-grid has an integral solution to the Pythagorean Theorem.
I have written the program to find the value of x as the lowest of the solution. That is: the {3, 4, 5} solution is shown but not the {4, 3, 5} solution. The program writes out its findings to a text data file on disk.
Dee