HP NW280-200X User Manual page 473

Prime graphing calculator
Table of Contents

Advertisement

FOR STEP
Programming
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
FOR k FROM 2 TO N DO
SIZE(idivis(k))
IF cur > max THEN
cur
max;
k
result;
END;
END;
MSGBOX("Max of "+ max +" factors for
"+result);
In Home, enter
MAXFACTORS(100).
This syntax is not
working as at build
3015.
Syntax: FOR var FROM start TO finish [STEP increment]
DO commands
Sets variable var to start, and for as long as this variable
is less than or equal to finish, executes the sequence of
commands, and then adds 1 (increment) to var.
Example 2: This program draws an interesting pattern on
the screen.
EXPORT DRAWPATTERN()
BEGIN
LOCAL xincr,yincr,color;
STARTAPP("Function");
RECT();
xincr := (Xmax - Xmin)/254;
yincr := (Ymax - Ymin)/110;
FOR X FROM Xmin TO Xmax STEP xincr DO
result;
cur;
467

Advertisement

Table of Contents
loading

Table of Contents