12-15-2013, 09:52 PM
From Page 531, 532 Prime User Manual
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;
END;
d+1 ▶ d;
END;
RETURN sum==n;
END;
The following program displays all the perfect numbers up
to 1000:
EXPORT PERFECTNUMS()
BEGIN
LOCAL k;
FOR k FROM 2 TO 1000 DO
IF ISPERFECT(k) THEN
MSGBOX(k+" is perfect, press OK");
END;
END;
END;
In the above bolded text, how is the test being performed? In HP50 RPL, it would be tested against a value in level 1 of the stack, but this appears to be an algebraic test. Thanks
rcf
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;
END;
d+1 ▶ d;
END;
RETURN sum==n;
END;
The following program displays all the perfect numbers up
to 1000:
EXPORT PERFECTNUMS()
BEGIN
LOCAL k;
FOR k FROM 2 TO 1000 DO
IF ISPERFECT(k) THEN
MSGBOX(k+" is perfect, press OK");
END;
END;
END;
In the above bolded text, how is the test being performed? In HP50 RPL, it would be tested against a value in level 1 of the stack, but this appears to be an algebraic test. Thanks
rcf