
Page 21-60
Using a FOR…NEXT loop:
«
0
→
n S
«
0 n FOR k k SQ S +
‘
S
‘
STO NEXT S
“
S
”
→
TAG
»
»
Store this program in a variable
@@S2@@
. Verify the following exercises:
J
3
@@@S2@@
Result:
S:14
4
@@@S2@@
Result:
S:30
5
@@@S2@@
Result:
S:55
8
@@@S2@@
Result:
S:204
10
@@@S2@@
Result:
S:385
20
@@@S2@@
Result:
S:2870
30
@@@S2@@
Result:
S:9455
100
@@@S2@@
Result:
S:338350
You may have noticed that the program is much simpler than the one stored in
@@@S1@@
. There is no need to initialize k, or to increment k within the program.
The program itself takes care of producing such increments.
The FOR…STEP construct
The general form of this statement is:
start_value end_value FOR loop_index program_statements
increment STEP
The start_value, end_value, and
increment
of the loop index can be
positive or negative quantities. For
increment > 0
, execution occurs as
long as the index is less than or equal to
end_value
. For
increment < 0
,
execution occurs as long as the index is greater than or equal to
end_value
.
Program statements are executed at least once (e.g.,
1 0 START 1 1 STEP
returns 1)
Example – generate a list of numbers using a FOR…STEP construct
Type in the program:
«
→
xs xe dx
«
xe xs – dx / ABS 1. +
→
n
«
xs xe FOR x
x dx STEP n
→
LIST
»
»
»
and store it in variable
@GLIS2
.
Содержание 48GII
Страница 1: ...hp 48gII graphing calculator user s guide H Edition 4 HP part number F2226 90020 ...
Страница 162: ...Page 3 37 Define this function by any of the means presented above and check that g 3 3 g 1 0 g 1 0 g 3 9 ...
Страница 201: ...Page 5 30 LIN LNCOLLECT POWEREXPAND SIMPLIFY ...
Страница 381: ...Page 11 55 Function KER Function MKISOM ...
Страница 461: ...Page 13 26 In the right hand side figure above we are using the line editor to see the series expansion in detail ...
Страница 777: ...Page 26 8 ...
Страница 840: ...Page L 5 ...