# Program Loops - HP 50g User Manual

Graphing calculator.

@@f3c@
5.6
@@f3c@
12
@@f3c@
23
As you can see, f3c produces exactly the same results as f3. The only
difference in the programs is the branching constructs used. For the case of
function f
(x), which requires five expressions for its definition, the CASE
3
construct may be easier to code than a number of nested IF ... THEN ... ELSE
... END constructs.

## Program loops

Program loops are constructs that permit the program the execution of a number
of statements repeatedly. For example, suppose that you want to calculate the
summation of the square of the integer numbers from 0 to n, i.e.,
To calculate this summation all that you have to do is use the ‚½ key
within the equation editor and load the limits and expression for the summation
(examples of summations are presented in Chapters 2 and 13). However, in
order to illustrate the use of programming loops, we will calculate this
summation with our own User RPL codes. There are four different commands
that can be used to code a program loop in User RPL, these are START, FOR,
DO, and WHILE. The commands START and FOR use an index or counter to
determine how many times the loop is executed. The commands DO and
WHILE rely on a logical statement to decide when to terminate a loop
execution. Operation of the loop commands is described in detail in the
following sections.
The START construct
The START construct uses two values of an index to execute a number of
statements repeatedly. There are two versions of the START construct:
START...NEXT and START ... STEP. The START...NEXT version is used when the
index increment is equal to 1, and the START...STEP version is used when the
index increment is determined by the user.
Result: -0.631266... (i.e., sin(x), with x in radians)
Result: 162754.791419 (i.e., exp(x))
Result
-2. (i.e., -2)
S
n
2
k
k
0
Page 21-53