While

"While" is a command found in the "program control" menu. It is used to test a condition, much like the "IF" command, however, it repeats the following commands (up until an "End" statement) until the "while" condition is no longer satisfied.

In the factoring algorithm, you test the factor pairs of a*c until you find two that add to be b. That is when the while loop would be terminated.


Subroutine

A subroutine is merely a program used inside another program. Simply enter "prgm" from the "program control" menu and type the program's name as the command line. It is sometimes easier to organize the program by calling smaller programs. Long code is much more difficult to dicipher when someone other than the creator is reading it.

In the factoring algorithm, you must determine the GCF. The TI does have a gcd( command already programmed, however, it only works if both values are positive. I wrote a prgmGCF to determine if the values are both postive, both negative, etc. and change them so that both are positive. Then the gcd( command on the TI can be used. I used "IF" statements to test whether the numbers are positive or negative. The subroutine prgmGCF returns the value of the greatest common factor regardless of what the signs are. Not using this may give an error message when negative numbers are entered as arguments.


RETURN to pgrmFACTOR

RETURN to General Commands