Jump to content
Science Forums

An algorithm to generate all the perfect right triangles


CraigD

Recommended Posts

In ”Re: Re perfect right triangles”, post #188 in “Katabatak Math-An Exploration In Pure Number Theory”, TheBigDog noted that, for the lengths of the side of a Right triangle, A, B, and C, are given by the famous Pythagorean formula:

A^2 + B^2 = C^2,

A^2 = 2*B + 1

for all odd positive integer values of A>1.

 

In a subsequent post, I noted that this is a special case of

A^2 = J*(2*B + J)

, followed by some unsatisfying (and incorrect) grumblings about “where A is not a multiple of N+1 (actually, something a bit more complicated I can't seem to find)”.

 

Here’s a more satisfying analysis and generalization:

 

A^2 + B^2 = C^2

can be rewritten:

A^2 + (B+I)^2 = (B+I+J)^2

and manipulated into:

(A*(A/J -2) -J)/2 = I;

(A^2/J -2*A -J)/2 = I

 

Taking A, I, and J to be positive integers, these forms assure that A is the shortest side (the “base”) of the right triangle, and promotes several observations:

J must evenly divide A^2; and

A/J be > 2

. From this, one can note that:

if A is prime, J can only be 1; and

A cannot be 1, 2, or 4.

 

Given this, it’s easy to write an (fairly efficient) algorithm to produce all A, J, I triplets. Here is one, along with output showing (A,J,I) and the associated triangle side lengths (in my favorite quick code, M[uMPS]):

f A=1:1 f J=1:1:A/2 s I=A-J-J*A-(J*J)/J/2 i I>0,I#1=0 w "(",A,",",J,") ",A,"x",A+I,"x",A+I+J,! r X
(3,1,1) 3x4x5
(5,1,7) 5x12x13
(6,2,2) 6x8x10
(7,1,17) 7x24x25
(8,2,7) 8x15x17
(9,1,31) 9x40x41
(9,3,3) 9x12x15
(10,2,14) 10x24x26
(11,1,49) 11x60x61
(12,2,23) 12x35x37
(12,4,4) 12x16x20
(13,1,71) 13x84x85
(14,2,34) 14x48x50
(15,1,97) 15x112x113
(15,3,21) 15x36x39
(15,5,5) 15x20x25
(16,2,47) 16x63x65
(16,4,14) 16x30x34
(17,1,127) 17x144x145
(18,2,62) 18x80x82
(18,6,6) 18x24x30
(19,1,161) 19x180x181
(20,2,79) 20x99x101
(20,4,28) 20x48x52
(20,8,1) 20x21x29
(21,1,199) 21x220x221
(21,3,51) 21x72x75
(21,7,7) 21x28x35
(22,2,98) 22x120x122
(23,1,241) 23x264x265
...
(1000,2,248999) 1000x249999x250001
(1000,4,123998) 1000x124998x125002
(1000,8,61496) 1000x62496x62504
(1000,10,48995) 1000x49995x50005
(1000,16,30242) 1000x31242x31258
(1000,20,23990) 1000x24990x25010
(1000,32,14609) 1000x15609x15641
(1000,40,11480) 1000x12480x12520
(1000,50,8975) 1000x9975x10025
(1000,80,5210) 1000x6210x6290
(1000,100,3950) 1000x4950x5050
(1000,160,2045) 1000x3045x3205
(1000,200,1400) 1000x2400x2600
(1000,250,875) 1000x1875x2125
(1000,400,50) 1000x1050x1450
(1001,1,499999) 1001x501000x501001
(1001,7,70567) 1001x71568x71575
(1001,11,44539) 1001x45540x45551
(1001,13,37531) 1001x38532x38545
(1001,49,9199) 1001x10200x10249
(1001,77,5467) 1001x6468x6545
(1001,91,4459) 1001x5460x5551
(1001,121,3079) 1001x4080x4201
(1001,143,2431) 1001x3432x3575
(1001,169,1879) 1001x2880x3049

:rainbow: Here’s a challenge:

Find a closed formula giving the number of perfect right triangles M(A) for a specific base length A.

Eg: M(3)=1; for M(9)=2; M(15)=3; M(1001)=10.

Link to comment
Share on other sites

Here’s a challenge:

Find a closed formula giving the number of perfect right triangles M(A) for a specific base length A.

Here’s what I’ve observed of potential use in this challenge:

We can take these observations to be theorems:

J must evenly divide A^2; and A/J be > 2
and add a slightly more subtle observation:

If A is evenly divisible by 2, J must be evenly divisible by 2.

 

Since the Fundamental Theorem of Arithmetic assures us that we can specify any positive integer as a unique product of prime factors, we can say this about the prime factors of A and J:

The factors of J must be selected from (0 or more of) the factors of A^2.

 

So, taking A=1001 as an example,

1001= 7 *11*13

1001^2 = 7*7 *11*11 *13*13

So taking every combination of (7, 7, 11, 11, 13, 13) with a product < A/2 gives us possible values of J: 1; 7; 11; 13; 7*7; 7*11; 7*13; 11*11; 11*13; 13*13

for M(1001)=10

or, for A=24

24^2= 2*2*2 *2*2*2 *3*3

J= 2; 2*2; 2*3; 2*2*2

for M(24)=5

which agrees with the output of the generating algorithm in post #1.

 

One approach to the challenge, then, is to rephrase it as 2 sub-problems:

1. Given a positive integer A, what are its prime factors?; and

2. Given a collection of prime factors, how many combinations have product < a given value (A/2, in our specific case).

 

#1 sounds suspiciously like a famous “hard” question, for which no existence proof is yet known.

 

Another approach is empirical. Given the sequence M(1), M(2), M(3) …:

0, 0, 1, 0, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 3, 2, 1, 2, 1, 3, 3, 1, 1, 4, 2, 1, 3, 3, 1, 3, 1, 3, 3, 1, 3, 5, 1, 1, 4, 5, 1, 3, 1, 3, 5, 1, 1, 6, 2, 2, 4, 3, 1, 3, 3, 5, 4, 1, 1, 8, 1, 1, 5, 4, 4, 4, 1, 3, 4, 3, 1, 8, 1, 1, 6, 3, 3, 4, 1, 7, 4, 1, 1, 9, 4, 1, 3, 6, 1, 5, 3, 3, 3, 1, 4, 9, 1, 2, 6, 6 …

or M(1), M(3), M(5) …:

0, 1, 1, 1, 2, 1, 1, 3, 1, 1, 3, 1, 2, 3, 1, 1, 3, 3, 1, 4, 1, 1, 5, 1, 2, 4, 1, 3, 4, 1, 1, 5, 4, 1, 4, 1, 1, 6, 3, 1, 4, 1, 4, 3, 1, 3, 3, 4, 1, 6, 1, 1, 9, 1, 1, 4, 1, 4, 6, 3, 2, 4, 3, 1, 4, 1, 4, 8, 1, 1, 4, 3, 4, 6, 1, 1, 5, 4, 1, 3, 4, 1, 9, 1, 2, 6, 1, 5, 3, 1, 1, 4, 4, 3, 8, 1, 1, 10, 1, 1 …

or M(2), M(4), M(6) …:

0, 0, 1, 1, 1, 2, 1, 2, 2, 3, 1, 4, 1, 3, 3, 3, 1, 5, 1, 5, 3, 3, 1, 6, 2, 3, 3, 5, 1, 8, 1, 4, 4, 3, 3, 8, 1, 3, 4, 7, 1, 9, 1, 6, 5, 3, 1, 9, 2, 6, 4, 6, 1, 8, 3, 7, 4, 3, 1, 15, 1, 3, 5, 5, 4, 10, 1, 6, 4, 10, 1, 12, 1, 3, 6, 6, 3, 10, 1, 10, 4, 3, 1, 13, 4, 3, 3, 8, 1, 16, 3, 6, 3, 3, 4, 11, 1, 6, 5, 10 …

can a sequence generating formula be found, paying no attention to how the sequence was generated?

 

:lol: I should caution that, often, when I post “challenges”, I have a suspicion that a solution may be impossible. Discovering that a problem has no solution, and why, can be as informative (and fun) as finding a solution.

I am working on it. But I feel like I am using stone tools while you have a modern machine shop.
I never cease to be surprised at when a stone tool suffices where a modern machine shop does not.

 

I must admit, however, that I love the ability to quickly write code to generate output like the above, and consider the somewhat obscure M[uMPS] language very handy for doing so, and an easy language to learn. I recall from your post #9 in “Repeating digits under long division”[/url] that you’re interested in creating some Visual BASIC code along these line, but think it might be worth your while to also work some in M. A free (in exchange for a name and email address) single user copy of a commercial implementation known as “Caché” can be had at http://intersystems.com/cache/downloads/index.html (this vendor is very good about not spamming or sharing your address).

Link to comment
Share on other sites

I never cease to be surprised at when a stone tool suffices where a modern machine shop does not.

 

I must admit, however, that I love the ability to quickly write code to generate output like the above, and consider the somewhat obscure M[uMPS] language very handy for doing so, and an easy language to learn. I recall from your post #9 in “Repeating digits under long division”[/url] that you’re interested in creating some Visual BASIC code along these line, but think it might be worth your while to also work some in M. A free (in exchange for a name and email address) single user copy of a commercial implementation known as “Caché” can be had at http://intersystems.com/cache/downloads/index.html (this vendor is very good about not spamming or sharing your address).

I appreciate the links Craig.

 

I am afraid the stone tools includes my proficiency with algebra. I am kinda looking at the number sets and trying to visualize patterns, then using a regressive process to find out the formula behind it.

 

I have a progam that is busily finding integer right triangles and writing them to a file. I am then using Access to do some initial inspection of the results. Along the way I am building some additional tools to further analyze the number set. One of the things I have done is to eliminate everything but the "base" triangles - so I see 3,4,5 but not 6,8,10. The interesting thing I have found so far is that 2 becomes the most common number of IRT (integer right triangles) with any number as the short leg. And also of note, having looked at all short legs up to 3000, all numbers up o 8 are represented for number of unique IRTs, but the number 5 never happens!

 

The current run is going to include a legs up to 5000.

 

Bill

Link to comment
Share on other sites

Good luck in your explorations, Bill. Sorry for calling you webeneton!

You might find this helpful – a VB equivalent of the code in post #1

Sub main()
For A = 1 To 25
For J = 1 To A / 2
 I = ((A / J - 2) * A - J) / 2
 If I > 0 And Int(I) = I Then
  Debug.Print "("; A; ","; J; ","; I; ") "; A; "x"; A + I; "x"; A + I + J
 End If
Next
Next
End Sub

By changing the For A from/to expressions, you can get it to duplicate post #1’s output (except for some VB-default whitespace - I can’t bear to uglify the code with Trim functions in every Print :lol:)

… And also of note, having looked at all short legs up to 3000, all numbers up o 8 are represented for number of unique IRTs, but the number 5 never happens! …
Isn’t 5x12x13 a base IRT with short leg 5? Other than 1, 2, and 4, I don’t believe any positive integer isn’t the short base of at least 1 BIRT.
Link to comment
Share on other sites

CraigD

 

Here is the busiest piece of code that have running.

 

For a = Val(Label1.Text) To Val(Label1.Text) + Val(TextBox1.Text)

Me.Text = Label1.Text & " - " & a & " - " & Val(Label1.Text) + Val(TextBox1.Text)

For b = a + 1 To Int(((a ^ 2) - 1) / 2)

c = Math.Sqrt((a ^ 2) + (b ^ 2))

If c = Int© Then

d = b / a

LogNow(a, b, c, d)

End If

Next b

Next a

 

It is taking a purely sequential approach. The LogNow calls a function that adds each result to a log file. I also read the log file before starting a run so I always continue where I left off. The text box and label values let me control from a UI instead of opening the code. I am going to start this up on a PC at work and let it run for a week or so to build a really good record set (and stop tying up my PC).

 

d is the ratio of b/a and I use it to find the "base" triangles in the analysis.

 

About the "base triangles" and 5 never happening, I am looking at each 'a' leg, and finding the number of unique right triangles with that value of 'a'. Here is what I see so far.

 

Num Count

1 1506

2 2764

3 843

4 1286

5 1

6 77

7 216

8 50

13 2

14 3

 

Num is the number of unique right triangles for a value of 'a'. Count is the number of values 'a' with that num. These go up to a values of 9000 for 'a' now. 5 did finally happen at a = 5040. But this is a really bizarre distribution curve!

 

Bill

Link to comment
Share on other sites

...Num is the number of unique right triangles for a value of 'a'. Count is the number of values 'a' with that num. These go up to a values of 9000 for 'a' now. 5 did finally happen at a = 5040. But this is a really bizarre distribution curve!

Gentlemen,

I see you have discovered PERTs! Prime Exact Right Triangles. (Prime means having no common integer divisor)

I discovered them accidently when I was 16, and soon found the following results:

The key to organizing PERTS is not the length of any side, but the DIFFERENCE in length between the longest side and the hypotenuse. I called these PERT Deltas. Each set of PERTs with a given Delta class is an infinite set. When charted, each Delta class graphs out what looks like a parabola. All the classes are nested and non-over-lapping. In each Delta class, the plotted triangle "points" skip certain intermediary points -- in different ways! You have to see this pattern visually to appreciate it. I will try to find my Excel analysis of PERTs I did several years ago.

 

The most common Deltas are 1, 2, 3...etc... But NOT 4!

 

And...there is a geometric way to generate all Delta=1 PERTS:

Draw positive Y axis and positive X axis. Nestle a circle of radius = 1 against the axes so that it kisses at Y=1 and X=1.

Draw a line from Y=3, tangent to the circle; it will intercept at X=4. You have the 3,4,5 PERT.

Take half the distance from Y=3 to Y=2 -- giving Y=2.5. Draw a line from there tangent to the circle; it will intercept at X=6. Multiple all sides by 2. You have the 5,12,13 PERT.

Repeat the last step, replacing Y=3 with Y=2.5.

Repeat the last step, replacing Y=2.5 with Y=2.25. -- Each time going half way from the previous Y value to Y=2.

Etc. etc.

 

This will generate the entire infinite set of Delta=1 PERTs. But none of the others!

Link to comment
Share on other sites

… But this is a really bizarre distribution curve!
It is, indeed, as I’ve found are most numbers generated by counting prime factors and combinations of prime factors.

 

I’ve a concern that your counting program may be ill. I tried reproducing it, and got the following distribution for number of base triangles with short leg A<=9000:

Num  Count
0    2252 
1    1862 
2    2710 
3    1073 
4    783 
5    79 
6    119 
7    110 
8    7 
10   3 
12   1 
13   1

Here are 2 examples of 5 base triangles with the same short side < 9000:

780x152099x152101

780x38021x38029

780x16891x16909

780x6059x6109

780x1421x1621

 

840x176399x176401

840x19591x19609

840x11009x11041

840x7031x7081

840x3551x3649

 

Here’s the M code that found the counts for A<=9000:

r XGCD,!
f  q:'N2  s GCD=N2,N2=N1#N2,N1=GCD ;find GCD of N1 & N2 –Euclid’s method
k C1 f A=1:1:9000 w A," " s C1=0 x "f J=1:1:A/2 s I=A-J-J*A-(J*J)/J/2 i I>0,'(I#1) s B=A+I,C=B+J,N1=A,N2=B x XGCD s N1=GCD,N2=C x:GCD>1 XGCD i GCD=1 s C1=C1+1" s C1(C1)=$g(C1(C1))+1 ;count

On my commodity laptop, it took about 90 sec – after I used Euclid’s method to find relative primes, instead of the crude divide-by-all-primes code I tried to use at first, which seemed like it would have taken all day!

Link to comment
Share on other sites

Gentlemen,

I see you have discovered PERTs! Prime Exact Right Triangles. (Prime means having no common integer divisor)

Good acryonym!
… The key to organizing PERTS is not the length of any side, but the DIFFERENCE in length between the longest side and the hypotenuse. I called these PERT Deltas.
What you called the PERT Delta, I named “J” in post #1
Each set of PERTs with a given Delta class is an infinite set. …
Very interesting observations. I look forward to exploring them in detail, and any old notes or new insights TheBigDog, Pyrotex, and any other numerophiles out there care to bring to the thread.
…The most common Deltas are 1, 2, 3...etc... But NOT 4!
I suspect this is algebraically provable, and will attempt it as time permits.
Link to comment
Share on other sites

I’ve a concern that your counting program may be ill. I tried reproducing it, and got the following distribution for number of base triangles with short leg A<=9000:

I am a bit baffled about that, but that is nothing new! I have found a couple of other issues as well and might just start it off on a fresh run.

 

On my commodity laptop, it took about 90 sec – after I used Euclid’s method to find relative primes, instead of the crude divide-by-all-primes code I tried to use at first, which seemed like it would have taken all day!

You got through the first 9000 in 90 seconds? DAMN! Mine took about 8 hours to get to 9000! And it missed some too?!?

 

I see you have discovered PERTs! Prime Exact Right Triangles. (Prime means having no common integer divisor)

I discovered them accidently when I was 16, and soon found the following results:

The key to organizing PERTS is not the length of any side, but the DIFFERENCE in length between the longest side and the hypotenuse. I called these PERT Deltas. Each set of PERTs with a given Delta class is an infinite set. When charted, each Delta class graphs out what looks like a parabola. All the classes are nested and non-over-lapping. In each Delta class, the plotted triangle "points" skip certain intermediary points -- in different ways! You have to see this pattern visually to appreciate it. I will try to find my Excel analysis of PERTs I did several years ago.

Pyro, thanks for the information. I have been thinking about how to begin charting some of this information. Those old Excel files would be cool to see. Did you find any patterns not in the j/delta/(c-:lol:, but rather in the (b-a)? I am intrigued about the pattern of right triangles that approach being isosceles.

 

Bill

Link to comment
Share on other sites

On my commodity laptop, it took about 90 sec – after I used Euclid’s method to find relative primes, instead of the crude divide-by-all-primes code I tried to use at first, which seemed like it would have taken all day!
You got through the first 9000 in 90 seconds? DAMN! Mine took about 8 hours to get to 9000! And it missed some too?!?
LOL. All the more reason to start using M[uMPS]/Caché!

 

Actually, for the program I ran, VB would be faster – M is an interpreted language, and has good but inefficient Math functions. The M program would likely have fewer characters in its source code, but wouldn’t be as fast as a compiled VB executable. The only time it will outperform most compiled code is when there are large, sorted arrays of data involved, which M can intrinsically do very efficiently.

 

I suspect you’re taking unnecessary time at:

For b = a + 1 … - here, you’re looping through about A^2/2 “I”s. My program loops through only A/2 “J”s. So, when it's in the 1000s, mine’s 1000+ times faster.

 

I’m not sure how you’re checking A, B, and C for common factors, but if you’re doing it as crudely as I was, you’re wasting time there, too.

Link to comment
Share on other sites

…The most common Deltas are 1, 2, 3...etc... But NOT 4!
I suspect this is algebraically provable, and will attempt it as time permits.
A proof’s pretty straightforward (though my shorthand may not be able to claim the same :lol: ):

A^2 + B^2 = C^2

let B=A+I, C=A+I+J

A^2 + (A+I)^2 = (A+I+J)^2

(A^2/J -2*A -J)/2 = I

assume J=4

then (A*(A/4 -2) -4)/2 = I

so A>8

A is divisible by 2

let A=2*K+8

((4*K^2+32*K+64)/4 -4*K -16 -4)/2 = I

K^2/2 +2*K -4 = I

so K is divisible by 2

let K=2*M

2*M^2 +4*K -4 = I

2*(M^2 +2*K -2) = I

so I is divisible by 2,

A, (A+I) and (A+I+J) are divisible by 2,

and (A,B,C) are not relatively prime.

 

However, a similar proof shows that 3, 5, 6 can’t be Deltas (J), either! Numeric methods show that 7, 10, 11, 12, 13, 14, 15, 16, 17, 19 … for A<=9000, all but 70 of 3600 Deltas can’t occur. Here’s the occurance frequency of those 70:

1:4499 2:2249 8:1123 9:822 18:415 25:715 32:558 49:404 50:355 72:176 81:264 98:246 121:320 128:271 162:140 169:262 200:170 225:116 242:139 288:84 289:180 338:108 361:150 392:87 441:81 450:41 512:122 529:105 578:72 625:120 648:46 722:60 729:59 800:71 841:84 882:36 961:87 968:56 1058:56 1089:50 1152:35 1225:49 1250:48 1352:42 1369:59 1458:26 1521:33 1568:28 1681:42 1682:30 1800:12 1849:37 1922:21 2025:16 2048:31 2178:13 2209:23 2312:13 2401:15 2450:7 2592:6 2601:9 2738:6 2809:6 2888:4 3025:1 3200:7 3362:2 3481:1 3528:2

 

Either I’m misunderstanding something, making both algebra and programming mistakes, or Pyrotex has understated the case of 4 being the only missing Delta. :eek_big: Can anyone produce an example of a PERT with Delta 3, 5, etc.?

Link to comment
Share on other sites

LOL. All the more reason to start using M[uMPS]/Caché!

 

Actually, for the program I ran, VB would be faster – M is an interpreted language, and has good but inefficient Math functions. The M program would likely have fewer characters in its source code, but wouldn’t be as fast as a compiled VB executable. The only time it will outperform most compiled code is when there are large, sorted arrays of data involved, which M can intrinsically do very efficiently.

 

I suspect you’re taking unnecessary time at:

For b = a + 1 … - here, you’re looping through about A^2/2 “I”s. My program loops through only A/2 “J”s. So, when it's in the 1000s, mine’s 1000+ times faster.

 

I’m not sure how you’re checking A, B, and C for common factors, but if you’re doing it as crudely as I was, you’re wasting time there, too.

I know that doing a full sequential search is going to hit a bunch of nothing, but I wanted to be sure that the formula you were using wasn't missing any that didn't fit its parameters (and then I missed some?!?). Like I said, algebra is a sharpened boulder in my hands. I am not too concerned about speed in the long run. I have some computers sitting around at work just collecting dust, so when I get the program just how I want it I am going to let one of them chew on it for a week or two and test the limits of the 'double' data type.

 

I created a function for myself called "IsPrime" that returns a boolean telling if the number passed is prime or not. In doing this the function starts a list of "known primes" to begin each search. It adds to the list if the current search extends past what it already knows. I am using that list as my foundation for another function I have yet to build that will return an array of the prime factors of any number passed to the function. It will pass the initial number into the "GetFactor" function and it will return the lowest prime factor. I then divide the original number by the return value and pass the result into the function. I repeat until the returned value equals the input value. This creates my array of factors. Once I have the factors for all the triangle's legs I will add them to my database in some relational method and be able to use query tools to plot and find patterns, etc.

 

But that is still under construction. So far I have used Excel to find the factors, but am limited to the dimensions of the spreadsheet. So It is only cursory at this time.

 

Bill

Link to comment
Share on other sites

However, a similar proof shows that 3, 5, 6 can’t be Deltas (J), either! Numeric methods show that 7, 10, 11, 12, 13, 14, 15, 16, 17, 19 … for A<=9000, all but 70 of 3600 Deltas can’t occur. Here’s the occurance frequency of those 70:

1:4499 2:2249 8:1123 9:822 18:415 25:715 32:558 49:404 50:355 72:176 81:264 98:246 121:320 128:271 162:140 169:262 200:170 225:116 242:139 288:84 289:180 338:108 361:150 392:87 441:81 450:41 512:122 529:105 578:72 625:120 648:46 722:60 729:59 800:71 841:84 882:36 961:87 968:56 1058:56 1089:50 1152:35 1225:49 1250:48 1352:42 1369:59 1458:26 1521:33 1568:28 1681:42 1682:30 1800:12 1849:37 1922:21 2025:16 2048:31 2178:13 2209:23 2312:13 2401:15 2450:7 2592:6 2601:9 2738:6 2809:6 2888:4 3025:1 3200:7 3362:2 3481:1 3528:2

 

Either I’m misunderstanding something, making both algebra and programming mistakes, or Pyrotex has understated the case of 4 being the only missing Delta. :lol: Can anyone produce an example of a PERT with Delta 3, 5, etc.?

Craig, If I follow that correctly you are including multiples of PERTs in your results, but I don't think they should be in there. IE 3x4x5 is a PERT, or as I was saying "base triangle", but 6x8x10 is not. So you would show a delta 3 for 9x12x15, and a delta 5 for 15x20x25 but you may not have a PERT with either of those deltas (J's).

 

Bill

Link to comment
Share on other sites

I created a function for myself called "IsPrime" that returns a boolean telling if the number passed is prime or not. In doing this the function starts a list of "known primes" to begin each search.
This is similar to what I was doing (I just used the list of numbers 2, 3, 5, 7, 9, 11, 13, 15 …) that caused my program to run so slowly at first.

 

Euclid’s GCD algorithm is much better for this use, and very simple. Here it is in M code:

f  q:'N2  s GCD=N2,N2=N1#N2,N1=GCD

or in (untested) Basic

Do
 If N2=0 Then Exit Do
 GCD= N2: N2= N1 mod N2: N1= GCD
Loop

To find if 3 numbers are relatively prime, you must call it twice as follows

N1= A: N2= B: call GCDalgorithm

N1=GCD: N2=C: call GCDalgorithm

If GCD > 1, A,B & C have it as a common factor.

Link to comment
Share on other sites

Craig, If I follow that correctly you are including multiples of PERTs in your results, but I don't think they should be in there. IE 3x4x5 is a PERT, or as I was saying "base triangle", but 6x8x10 is not.

 

Correct. PERT, as I defined it, is a set of relatively prime triangles. 6x8x10 is not a PERT.

I may have mislead you guys on the Delta=4 thingie. It has been a few years since I studied PERTs, though I have been doing so for 43 years, off and on. I DO remember that 4 was forbidden as a Delta. As for 3, 6 and the others, I really don't remember.

 

I am looking for that last spreadsheet where I calculated PERTs, categorized them and plotted the PERT Delta Classes. I am also REAL busy right now, as we are doing a proposal for NASA to build a commercial cargo carrier for LEO. The Game is Afoot!!!

Link to comment
Share on other sites

Craig, If I follow that correctly you are including multiples of PERTs in your results, but I don't think they should be in there. IE 3x4x5 is a PERT, or as I was saying "base triangle", but 6x8x10 is not. So you would show a delta 3 for 9x12x15, and a delta 5 for 15x20x25 but you may not have a PERT with either of those deltas (J's).

 

Bill

The “1:4499 2:2249 8:1123 9:822 18:415 25:715 …” count of PERTs by J excludes triangles with side lengths that are not relatively prime such as 6x8x10. It would not exclude triples that are not pairwise relatively prime, such as (2,6,9), although I suspect (but haven’t verified) that no such right triangles exist. I suspect that A & B are relatively prime for all PERTs.

 

The distribution including non-PERT triangles such as 6x8x10, is:

1:4499 2:4498 3:1499 4:2248 5:899 6:1498 7:642 8:2246 9:1321 10:898 11:408 12:748 13:345 14:640 15:299 16:1121 17:264 18:1330 19:236 20:448 21:213 22:407 23:195 24:746 25:894 26:344 27:431 28:319 29:154 30:298 31:144

3528:3 3536:1 3544:1 3552:1 3560:1 3568:1 3576:1 3584:2 3592:1 3600:1

It has 3097 counts. I believe the missing Js are due to stopping the count at 9000, and would be filled in as the max count is increased.

 

What value J can have for a PERT – the 70 in post #12, for PERTs with A<=9000 - is an interesting question. I believe it can be answered by generalizing the proof that all triangles with J=4 have a sides with a common factor of 2. A simpler approach exists as well, I think, based on the observation that, including non-PERT perfect right triangles, J may have any positive integer value.

 

Though an enjoyable Algebra and programming exercise for everybody, I don’t sense this thread leading to any world-shaking conclusions. My fascination with algebra and numeric methods involving prime numbers does have a deep and potential world-shaking motive. The old thread 3203 gives the problem a solution to which I believe would be so important, but doesn’t go into any detail about why it would be so important. Threads like these are, from my perspective, attempts to cultivate mathematical intuition that could be helpful in the Starburst problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...