Programming in HP PPL 531
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;
2 ▶ d;
1 ▶ sum;
WHILE sum <= n AND d < n DO
IF irem(n,d)==0 THEN
sum+d ▶ sum;