HP 39gII User Manual page 280

Graphing calculator
Hide thumbs Also See for 39gII:
Table of Contents

Advertisement

270
Evaluate test. If result is true (non 0), executes the
commands, and repeat.
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. This function returns true
when its argument is a perfect number.
Example:
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
END;
d+1 d;
END;
RETURN sum==n;
END;
This 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;
sum;
Programming

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents