Education Technology

Solution 11734: Creating Repetition in a TI Basic Program on the TI-89 Family, TI-92 Family, and Voyage™ 200 Graphing Calculators.

How can I create a repetition in a TI Basic program on the TI-89 Family, TI-92 Family, and Voyage 200?

There are three structures that allow to program tasks that repeat. The three repetition structures are:

• The Loop...EndLoop.
• The For ...EndFor.
• The While...EndWhile.

Each structure is different in its use and provide a unique advantage.

Use the Loop..EndLoop when the number of times needs to be repeated is not known. It must include an exit condition allowing to leave the loop. The program will repeat the loop until the condition is met. It will then exit and execute the first statement after EndLoop. The loop will be executed endlessly, unless a Goto or Exit instruction is executed.

Program segment example:

:...
:1->i
:Loop
:Rand(6)->die1
:Rand(6)->die2
:If die1=6 and die2=6
:Goto End
:i+1->i
:EndLoop
:Lbl End
:Disp "The number of rolls is",i
:...

Use the For...EndFor when the number of times the loop should be repeated is known.

Program segment example:

:...
:0->tempsum
:0->step
:For i,1,100,step
:tempsum+i->tempsum
:EndFor
:Disp tempsum
:...

Please Note: After the segment above executes, the content of the variable tempsum is 5050.

Use the While...EndWhile when testing the condition is important. The block will execute as long as the condition is true.

Program segment example:

:...
:1->i
:0->temp
:While i <= 20
:temp+1/i->temp
:1+i->i
:EndWhile
:Disp "sum of reciprocal up to 20", temp
:...

Please see the TI-89 family, TI-92 family, and Voyage 200 guidebooks for additional information.