HP 48gII User Manual
Page 703
Page 21-54
„°@)@BRCH@ @)START @START
Within the BRCH menu („°@)@BRCH@) the following keystrokes are available
to generate START constructs (the symbol indicates cursor position):
• „ @START
: Starts the START…NEXT construct: START
NEXT
• ‚ @START
: Starts the START…STEP construct: START
STEP
The START…NEXT construct
The general form of this statement is:
start_value end_value START program_statements NEXT
Because for this case the increment is 1, in order for the loop to end you
should ensure that start_value < end_value. Otherwise you will
produce what is called an infinite (never-ending) loop.
Example – calculating of the summation S defined above
The START…NEXT construct contains an index whose value is inaccessible to
the user. Since for the calculation of the sum the index itself (k, in this case) is
needed, we must create our own index, k, that we will increment within the
loop each time the loop is executed. A possible implementation for the
calculation of S is the program:
«
0. DUP
→ n S k
«
0. n START k SQ S + 1.
‘k‘ STO+ ‘S‘ STO
NEXT S
“S” →TAG » »
Type the program in, and save it in a variable called
@@@S1@@@.
Here is a brief explanation of how the program works:
1. This program needs an integer number as input. Thus, before execution,
that number (n) is in stack level 1. The program is then executed.