268
Programming
causes the name of the selected person will be printed to
the terminal.
Loop commands
FOR…FROM…TO…
DO…END
Syntax:
FOR
var
FROM
start
TO
finish
[
STEP increment
]
DO
commands
END
;
Sets variable
var
to start, and for as long as this variable's
value is less than or equal to
finish
, executes the sequence
of
commands
, and then adds 1 (
increment
) to
var
.
Example 1: This program determines which integer from
2 to N has the greatest number of factors.
EXPORT MAXFACTORS(N)
BEGIN
LOCAL cur, max,k,result;
1
max;1
r
esult;
FOR k FROM 2 TO N DO
SIZE(idivis(k))
cur;
IF cur > max THEN
cur
max;
k
result;
END;
END;
MSGBOX(
"Max of "+ max +" factors for
"+result
);
In Home, enter
MAXFACTORS
(100).
Example 2: This program draws an interesting pattern on
the screen.
Summary of Contents for 39gII
Page 1: ...HP 39gII graphing calculator user s guide Edition1 Part Number NW249 90001 ...
Page 2: ...Printing History Edition 1 November 201 1 ...
Page 32: ...22 Getting started ...
Page 58: ...48 Apps and their views ...
Page 70: ...60 Function app ...
Page 80: ...70 Solve app ...
Page 136: ...126 Polar app ...
Page 140: ...130 Sequence app ...
Page 148: ...138 Finance app ...
Page 152: ...142 Linear Solver app ...
Page 218: ...208 Matrices ...
Page 226: ...216 Notes and Info ...
Page 238: ...228 Variables and memory management ...
Page 318: ...308 Programming ...
Page 340: ...330 Reference information ...
Page 346: ...vi Product Regulatory Information ...