IDENTIFICATION DIVISION.
PROGRAM-ID. aising-C.
DATA DIVISION.
*>
WORKING-STORAGE SECTION.
01 N          PIC  9(05) COMP.
01 I          PIC  9(04) COMP.
01 X          PIC  9(04) COMP.
01 Y          PIC  9(04) COMP.
01 Z          PIC  9(04) COMP.
01 V          PIC  9(09) COMP.
01 TBL.
   03 T       PIC  9(03) OCCURS 10000.
01 OUT        PIC  ZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  MOVE ZERO TO TBL.
  PERFORM VARYING X FROM 1 BY 1 UNTIL X > 100
    PERFORM VARYING Y FROM 1 BY 1 UNTIL Y > 100
      PERFORM VARYING Z FROM 1 BY 1 UNTIL Z > 100
        COMPUTE V = X * X + Y * Y + Z * Z + X * Y + Y * Z + Z * X
        IF V <= 10000
          ADD 1 TO T(V)
        END-IF
      END-PERFORM
    END-PERFORM
  END-PERFORM.
*>
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    MOVE T(I) TO OUT
    DISPLAY FUNCTION TRIM(OUT)
  END-PERFORM.
*>
  STOP RUN.
