I wrote a decent program for reducing radicals, but the problem is that is runs far too slowly. I was hoping that somebody could analyze what I did and help me to speed things up.
PROGRAM:REDURAD :ClrHome :Disp "sqrt(A)" :Prompt A :If A<0 :Then :Disp "ERROR:" :Disp "IMAGINARY" :Return :End :If A=0 :Then :Output(4,3,"0") :Return :End :If A=1 :Then :Output(4,3,"1") :Return :End %The previous two IF statements were my way of compensating for the fact that REPEAT always runs at least one time, even if the condition is true the first time. I was hoping you could show me a better way. I do the same thing later on in the program :int(A/2)->I :Repeat not(fPart(A/I^2)) :If I>=1 and I<=2 :Then :If not(fPart(A/I^2) :Goto Z :End :I-1->I :End :Lbl Z :A/I^2->B :If I=1 :Then :Disp "IRREDUCIBLE" :Return :End :If I!=1 :Output(4,3,I) :1->J :If I<10 :Then :Goto Y :End :Repeat(I<10^J) :J+1->J :If B!=1 :Then :Output(4,3+J,"sqrt(") :Output(4,3+J+1,B) :Return :End :Lbl Y :If B!=1 :Then :Output(4,4,"sqrt(") :Output(4,5,B) :End