HP Prime Graphing NW280AAABA manual Rect, END Wait, Export ISPERFECTn

Models: Prime Graphing NW280AAABA

1 616
Download 616 pages 24.49 Kb
Page 537
Image 537

RECT();

xincr := (Xmax - Xmin)/318; yincr := (Ymax - Ymin)/218;

FOR X FROM Xmin TO Xmax STEP xincr DO FOR Y FROM Ymin TO Ymax STEP yincr DO color := RGB(X^3 MOD 255,Y^3 MOD 255, TAN(0.1*(X^3+Y^3)) MOD 255); PIXON(X,Y,color);

END;

END;

WAIT;

END;

FOR DOWN Syntax: FOR var FROM start DOWNTO finish DO commands END;

Sets variable var to start, and for as long as this variable is more than or equal to finish, executes the sequence of commands, and then subtracts 1 (decrement) from var.

FOR DOWN STEP Syntax: FOR var FROM start DOWNTO finish [STEP increment] DO commands END;

Sets variable var to start, and for as long as this variable is more than or equal to finish, executes the sequence of commands, and then subtracts increment from var.

WHILE Syntax: WHILE test DO commands END;

Evaluates test. If result is true (not 0), executes the commands, and repeats.

Example: A perfect number is one that is equal to the sum of all its proper divisors. For example, 6 is a perfect number because 6 = 1+2+3. The example below returns true when its argument is a perfect number.

EXPORT ISPERFECT(n)

BEGIN

LOCAL d, sum;

2d;

1sum;

WHILE sum <= n AND d < n DO IF irem(n,d)==0 THEN sum+d sum;

Programming in HP PPL

531

Page 537
Image 537
HP Prime Graphing NW280AAABA manual Rect, END Wait, Export ISPERFECTn