# TITLE: Selected Pythagorean Triples # AUTHOR: BazzaB # EMAIL: barries_ecdl@hotmail.com # DATE: 1st December 2003 # MAKE: Casio # MODEL: CFX-9850G or similar # NOTES: A 'pythagorean triple' contains those integer sides of a 90 degree # triangle where if c is the hypotenuse and a and b are the other two sides, # then a squared + b squared = c squared. # There are an infinite amount of them, so I've just programmed for an upper # limit for side c of 1 million or so, except for the Opening Menu choice F1. # Only "primitive" triples are generated. For example, the triple 15 112 113 is # primitive because it is not a multiple of any other, but 6 8 10 is not # primitive because it is just a magnified version of the triangle with sides # of 3 4 5. # # On each Menu screen you have a choice of pressing the function keys F1, F2 or # F3, depending on what you want. After having pressed any of those for a # particular sequence and a chosen range, you will be shown the first triple and # now you have to press the EXE key for the next one. You keep the EXE key # permanently pressed until the value for side c that you are interested in # swims into view. Be careful, because the numbers change pretty rapidly. # For example, if you want to investigate those triples where sides a and c are # consecutive odd numbers with c equal to 700 000 or more, then your function # keys presses would be F2, F3, F3. Now keep the EXE key pressed until the # bottom line reads something like 688901 or 692225 or 698897, and then release # it. Now do single presses until the triple 702243, 1676, 702245 is shown. # # If you are looking for the largest triple in any range then just keep the # EXE key pressed down until the message 'LAST VALUE NEXT' appears. This gives # you about three seconds to take your finger off. Once you've done that, wait a # second and press EXE just the once. Of course, one more press and you are back # to the Opening Menu screen. # KEYS: # -> assignment above [ AC/ON ] # => if-then shift vars f3 f3 # <> not equal shift vars f6 f3 f2 # \10^ 10 to the power small 10. shift [ log ] # [ left bracket shift [ + ] # ] right bracket shift [ - ] # Mat matrix optn f2 f1 #__________________________________________________ @@ Program "SELTRIP" # Needs Subroutine "S-F1F6" shown at the end of the main listing. Lbl A Norm:ClrText:[[3,4,5]]->Mat B:0->A~G Locate 4,1,"A SELECTION OF":Locate 2,2,"PYTHAGOREAN TRIPLES" Locate 1,4,"F1= A,B CONSECUTIVE" Locate 1,5,"F2= A,C CONSEC ODD" Locate 1,6,"F3= B,C CONSECUTIVE" 1->G:3->D:Prog "S-F1F6" [[2,1,2][1,2,2][2.2.3]]->Mat A:13->C:D=1=>Goto C D=2=>[[-1,-2,-2][2,1,2][2,2,3]]->Mat A D=3=>[[1,2,2][-2,-1,-2][2,2,3]]->Mat A:D=3=>Goto B 1->F:Goto D Lbl 1 49->C:D=1=>Goto C [[9999,200,10001]]->Mat B:109->C:D=2=>Goto C 2->F:Goto E Lbl 2 [[101123,636,101125]]->Mat B:115->C:D=1=>Goto C [[300303,1096,300305]]->Mat B:114->C:D=2=>Goto C [[602175,1552,602177]]->Mat B:112->C:Goto C Lbl B 3->F:Goto D Lbl 3 70->C:D=1=>Goto C [[143,10224,10225]]->Mat B:153->C:D=2=>Goto C 4->F:Goto E Lbl 4 [[449,100800,100801]]->Mat B:163->C:D=1=>Goto C [[775,300312,300313]]->Mat B:161->C:D=2=>Goto C [[1097,601704,601705]]->Mat B:159->C ' RESULTS Lbl C Do:Isz B:Mat B(Mat A For 1->A To 3:Locate 3,A+2,Mat B[1,A]:Next Mat Ans->Mat B If B=C-1:Then Locate 1,1,"LAST VALUE NEXT":For 1->D To 500:Next:IfEnd If B=C:Then locate 1,7,"END..":Locate 12,1," ":IfEnd ; 4 spcs While Getkey<>31:WhileEnd:LpWhile B 9999" For 4->A To 5:Locate 1,A,"F":Locate 2,A,A-2:Locate 3,A,"=":Locate 13,A"->" Locate 11-A,A,\10^A:Locate 15,A,\10^(A+1)-1:Next 1->G:3->D:Prog "S-F1F6":F=1=>Goto 1:Goto 3 Lbl E "RANGE FOR SIDE C ?":Locate 1,3,"F1= 100000 -> 299999" Locate 1,4,"F2= 300000 -> 599999":Locate 1,5,"F3= 600000 -> 999999" 1->G:3->D:Prog "S-F1F6":F=2=>Goto 2:Goto 4 #_________________________________________________________________ @@ Program "S-F1F6" # This subroutine only allows a specified range of the F1 to F6 function keys # to operate for things like 'Menu Choices.' # The value of G on entry is set to the lower limit, and D is set to the upper. # E and D on exit hold the value of the pressed 'F' number, from 1 to 6. Do 0->E While E=0 Getkey->E WhileEnd .1(89-E->E LpWhile Frac E+(ED E->D ClrText #_________________________________________________________________