09-25-2019, 10:33 PM
I wrote the following program for the HHC programming contest. I didn't submit it because it frequently (but not always) crashed my Prime G2. I just verified that it crashes the virtual calculator also.
If I debug the program, press STEP a few times and CONT, it will run until the last statement (RETURN L1 and pause there. Pressing STEP causes it to crash.
Both the physical and virtual calcs are running the 20181016 version. I tried reformatting the C drive on the physical calculator but that didn't help. Any thoughts?
The program finds 3-digit numbers that are equal to the sum of the cubes of their digits.
Thanks,
Dave
If I debug the program, press STEP a few times and CONT, it will run until the last statement (RETURN L1 and pause there. Pressing STEP causes it to crash.
Both the physical and virtual calcs are running the 20181016 version. I tried reformatting the C drive on the physical calculator but that didn't help. Any thoughts?
The program finds 3-digit numbers that are equal to the sum of the cubes of their digits.
Thanks,
Dave
Code:
EXPORT CUBES()
BEGIN
LOCAL S1:=0,S2:=0,S3:=0; // PARTIAL SUMS
LOCAL N1:=0,N2:=0,N3:=0,C:=0; // THE NUM
LOCAL L1 := {};
LOCAL X,Y,Z;
FOR X FROM 1 TO 9 DO
S1 := X*X*X;
N1 := 100*X;
FOR Y FROM 0 TO 9 DO
S2 := S1 + Y*Y*Y;
N2 := N1 + 10*Y;
FOR Z FROM 0 TO 9 DO
S3 := S2 + Z*Z*Z;
N3 := N2 + Z;
IF S3 > N2+9 THEN
// PRINT("LEAVING W"+N3);
BREAK;
END;
C:=C+1;
IF N3 = S3 THEN
L1 := CONCAT(L1,N3);
END;
END;
END;
END;
// PRINT(C);
RETURN L1;
END;