The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Program crashes G2
09-25-2019, 10:33 PM
Post: #1
Program crashes G2
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 L1Wink 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;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Program crashes G2 - David Hayden - 09-25-2019 10:33 PM
RE: Program crashes G2 - Albert Chan - 09-25-2019, 11:15 PM
RE: Program crashes G2 - Gene222 - 09-26-2019, 02:18 AM
RE: Program crashes G2 - toml_12953 - 09-26-2019, 07:00 AM
RE: Program crashes G2 - David Hayden - 09-26-2019, 11:36 AM
RE: Program crashes G2 - grsbanks - 09-26-2019, 01:18 PM



User(s) browsing this thread: 1 Guest(s)