Skip to main content

Integer Cube

·
Table of Contents

hp-prime
hp-prime

Description #

#pragma mode( sepa`ator(.,;) integer(b64) )

EXPORT Integer_Cube(Maximum)
BEGIN
  LOCAL A,B,C,D;
  LOCAL Retval=[[0,0,0,0]];

  FOR A FROM 1 TO Maximum DO
    FOR B FROM A TO Maximum DO
      FOR C FROM B TO Maximum DO
	D := 3 NTHROOT (A^3+B^3+C^3);
	IF FP(D) == 0 THEN
	  ADDROW (Retval, [A,B,C,D], rowDim (Retval) + 1);
	END;
      END;
    END;
  END;

  DELROW (Retval, 1);
  RETURN Retval;
END;
Download HP-Prime/Integer_Cube.prime