# Using Summations Instead Of Loops; Using Flags - HP 48gII Advanced User's Reference Manual

Graphing calculator.

## Using Summations Instead of Loops

For certain calculations that involve summations, you can use the
with stack syntax or with algebraic syntax.
index variable — without using a loop structure.
Example:
The following programs take an integer upper limit n from the stack, then find the summation. One
program uses a FOR ... NEXT loop — the other uses
n
2
j
Program:
j
=
1
«
0 1 ROT
FOR j
NEXT
"
Program:
«
 n
'...(j=1,n,j^2)'
"
Example:
The following program uses LIST to calculate the summation of all elements of a vector or matrix.
The program takes from the stack an array or a name that evaluates to an array, and returns the summation.
Program:
«
OBJ
1
+
œLIST
LIST
...LIST
"

### Using Flags

You can use flags to control calculator behavior and program execution. You can think of a flag as a switch that
is either on (set) or off (clear). You can test a flag's state within a conditional or loop structure to make a
automatically repeats the addition for the specified range of the
j SQ +
Finds the dimensions of the array and
leaves it in a list on level 1.
Adds 1 to the list. (If the array is a vector,
the list on level 1 has only one element.
ΠLIST will error if the list has fewer than
two elements.)
Multiplies all of the list elements together.
Converts the array elements into a list, and
sums them.
function instead of loops. You can use
Initializes the summation and puts
the limits in place.
Loops through the calculation.
Uses
to calculate the summation.
RPL Programming 1-25